1.搜索centos7默认的Mariadb数据库
rpm -qa | grep mariadb
2.卸载Mariadb
rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
3.下载mysql的repo源
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
4.安装mysql
sudo yum install mysql-server -y
5.修改my.cnf,添加character-set-server=utf8解决中文乱码
vim /etc/my.cnf
在socket=/var/lib/mysql/mysql.sock下面添加character-set-server=utf8解决中文乱码
character-set-server=utf8
6.给mysql文件授权
sudo chown -R root:root /var/lib/mysql
chown root /var/lib/mysql/
7.重启服务
service mysqld restart
8.登录mysql
mysql -u root -p
到了Enter password:直接回车
9.开启mysql数据库密码和远程登录权限
use mysql;
8.1设置密码为ok
update user set password=password('ok') where user='root';
8.2开启远程登录权限
GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "ok";
8.3重新启动mysql服务器,来使新设置生效
flush privileges;
8.4退出
exit;
10.重启服务
service mysqld restart
|