1.安装包准备
2.卸载自带MySQL
卸载MySQL
rpm -qa | grep -i mysql
rpm -e --nodeps mysql-xxx
删除MySQL残留文件
find / -name mysql
rm -rf xxx
卸载MariaDB
rpm -qa | grep -i mariadb
3.安装MySQL
安装软件
rpm -ivh MySQL-server-5.6.42-1.el7.x86_64.rpm
rpm -ivh MySQL-devel-5.6.42-1.el7.x86_64.rpm
rpm -ivh MySQL-client-5.6.42-1.el7.x86_64.rpm
修改配置文件
cp /usr/share/mysql/my-default.cnf /etc/my.cnf
vim /etc/my.cnf
[client] password=root port=3306 default-character-set=utf8 [mysqld] port=3306 character_set_server=utf8 character_set_client=utf8 collation-server=utf8_general_ci #(注意linux下mysql安装完后是默认:表名区分大小写,列名不区分大小写; 0:区分大小写,1:不区分大小写) lower_case_table_names=1 ##(设置最大连接数,默认为 151,MySQL服务器允许的最大连接数16384; ) max_connections=1000 [mysql] default-character-set = utf8
初始化数据库
/usr/bin/mysql_install_db
service mysql start
查看root账号密码
cat /root/.mysql_secret
登陆修改密码
mysql -uroot -p密码
mysql> SET PASSWORD = PASSWORD('密码');
mysql> exit
mysql -uroot -p密码
允许远程登陆
mysql> grant all privileges on *.* to 'root'@'%' identified by '密码';
——'root'@'%'中 %代表所有主机
mysql> flush privileges;
mysql> exit
设置开机自启动
chkconfig mysql on
chkconfig --list | grep mysql