1. 找到MySQL的配置文件,一般在MySQL的安装目录下,例如我的: C:\Program Files\MySQL\MySQL Server 5.7 ,打开下面的一个配置文件: my-default.ini ,在最后面添加一行配置: show_compatibility_56 = 1 。
2. 重启MySQL让设置生效。
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
实际用:tar -zxvf mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
实际用:ln -s /usr/local/mysql-5.7.9-linux-glibc2.5-x86_64 mysql
shell> cd mysql
shell> mkdir mysql-files
shell> chmod 770 mysql-files
修改目录的拥有者:
shell> chown -R mysql .
shell> chgrp -R mysql .
这里的点“.”代表的就是当前目录,选项-R表示递归当前目录及其子目录。
shell> bin/mysqld --initialize --user=mysql
注意:生成的初始用户名和密码要复制出来.用来首次登录和修改密码.
shell> bin/mysql_ssl_rsa_setup
shell> chown -R root .
shell> chown -R mysql data mysql-files
出现一个坑。在mysql目录下 创建:mkdir data
![](https://i-blog.csdnimg.cn/blog_migrate/9c3c93f36936f24063a5c8bdd67b4044.png)
![](https://i-blog.csdnimg.cn/blog_migrate/13eb14097f2c2dcba5912ca182a3820f.png)
先用mv /etc/my.cnf 文件再删除,如:
mv /etc/my.cnf /etc/my.cnf.bak
然后从 初始化生成用户名和密码这步,再新走起。以下重复开始
cd ..
bin/mysqld --initialize --user=mysql
shell> bin/mysqld_safe --user=mysql &
上一条指令执行成功之后 用此命令 ps -ef|grep mysqlld 查看是否启动成功:
ps -aux|grep mysqlld也可以
以上重复结束
接下来是,安装可选项
shell> cp support-files/mysql.server /etc/init.d/mysql.server 加入开机自启动项
配置环境变量:
vi /etc/profile
export PATH=/usr/local/mysql/bin:$PATH 文件尾部加入
source /etc/profile
chkconfig --list
配置开启启动 chkconfig mysql.server on
chkconfig --list
登陆
mysql -uroot -p 初始化密码
修改密码 set password = 'root1234';
允许远程登陆 授权
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root1234';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root1234' WITH GRANT OPTION;
flush privileges;
用客户端工具测试链接,有问题时:
1:firewall-cmd --state 查看防火墙的状态
临时关闭防火墙。
2:systemctl stop firewalld.service
禁止防火墙开机启动
3:systemctl disable firewalld.service