安装包下载链接下载链接
https://dev.mysql.com/downloads/file/?id=492142

[root@localhost ~]# ls  //查看压缩包
anaconda-ks.cfg  Desktop  Documents  Downloads  initial-setup-ks.cfg  Music  mysql-5.6.47-linux-glibc2.12-x86_64.tar.gz  Pictures  Public  Templates  Videos
[root@localhost ~]# tar -zxf mysql-5.6.47-linux-glibc2.12-x86_64.tar.gz   //解压
[root@localhost ~]# ls
anaconda-ks.cfg  Documents  initial-setup-ks.cfg  mysql-5.6.47-linux-glibc2.12-x86_64         Pictures  Templates
Desktop          Downloads  Music                 mysql-5.6.47-linux-glibc2.12-x86_64.tar.gz  Public    Videos
[root@localhost ~]# mv mysql-5.6.47-linux-glibc2.12-x86_64 /usr/local/mysql   //移动到/usr/local/mysql
[root@localhost ~]# useradd -r -s /sbin/nologin mysql    //创建系统用户
[root@localhost ~]# chown -R mysql.mysql /usr/local/mysql    //更改文件拥有者
[root@localhost ~]# ls /usr/local/mysql     //查看一下里面已经有东西了
bin  data  docs  include  lib  LICENSE  man  mysql-test  README  scripts  share  sql-bench  support-files
[root@localhost ~]# ll /usr/local/mysql/data    //看一下还没有东西
total 0
drwxr-xr-x. 2 mysql mysql 20 Dec  5 09:54 test
[root@localhost ~]# cd /usr/local/mysql  //进来这里
[root@localhost mysql]# scripts/mysql_install_db  --user=mysql  //初始化数据库
[root@localhost mysql]# ll data //有东西了
total 110600
-rw-rw----. 1 mysql mysql 12582912 Dec  5 10:19 ibdata1
-rw-rw----. 1 mysql mysql 50331648 Dec  5 10:19 ib_logfile0
-rw-rw----. 1 mysql mysql 50331648 Dec  5 10:19 ib_logfile1
drwx------. 2 mysql mysql     4096 Dec  5 10:19 mysql
drwx------. 2 mysql mysql     4096 Dec  5 10:19 performance_schema
drwxr-xr-x. 2 mysql mysql       20 Dec  5 09:54 test
[root@localhost mysql]# cp support-files/mysql.server  /etc/init.d/mysql  //移动脚本etc/init.d一份
[root@localhost mysql]# service mysql start  //启动mysql脚本
Starting MySQL.Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
 SUCCESS! 
[root@localhost mysql]# bin/mysqladmin -u root password '123' //设置密码
Warning: Using a password on the command line interface can be insecure.
[root@localhost mysql]# bin/mysql -u root -p //进入数据库 报错
bin/mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
[root@localhost mysql]# ln -s /lib64/libtinfo.so.6 /lib64/libtinfo.so.5 //创建连接
[root@localhost mysql]# bin/mysql -u root -p  //成功
Enter password: 
[root@localhost ~]# mysql -uroot -p  //返回目录 报错 由于系统默认查找/usr/bin下的命令,如果这个命令不在这个目录下,当然会找不到命令
bash: mysql: command not found...
[root@localhost ~]# cd /usr/local/mysql //mysql安装命令安装这里的bin/mysql中
[root@localhost mysql]# ln -s /usr/local/mysql/bin/mysql /usr/bin   //创建连接
[root@localhost ~]# mysql -uroot -p  //回到家目录可以
Enter password: 

原文地址:https://blog.csdn.net/weixin_45663220/article/details/134802658

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_48104.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注