先介绍卸载
yum方式
查看yum是否安装过mysql yum list installed mysql*
如或显示了列表,说明系统中有MySQL
yum卸载
根据列表上的名字yum remove mysql-community-client mysql-community-common mysql-community-libs mysql-community-libs-compat mysql-community-server mysql57-community-release rm -rf /var/lib/mysql rm /etc/my.cnf
rpm查看安装
rpm -qa | grep -i mysql
rpm 卸载
rpm -e mysql57-community-release-el7-9.noarch rpm -e mysql-community-server-5.7.17-1.el7.x86_64 rpm -e mysql-community-libs-5.7.17-1.el7.x86_64 rpm -e mysql-community-libs-compat-5.7.17-1.el7.x86_64 rpm -e mysql-community-common-5.7.17-1.el7.x86_64 rpm -e mysql-community-client-5.7.17-1.el7.x86_64 cd /var/lib/ rm -rf mysql/
清除余项
whereis mysql mysql: /usr/bin/mysql /usr/lib64/mysql /usr/local/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz #删除上面的文件夹 rm -rf /usr/bin/mysql
…
…
我就省略了删除配置
rm –rf /usr/my.cnf rm -rf /root/.mysql_sercret
剩余配置检查
chkconfig --list | grep -i mysql chkconfig --del mysqld
根据上面的列表,删除 ,如:mysqld
再介绍安装
注意
yum源,阿里的CentOS7.repo是没有的,国外源相当慢,做好心理准备。下载地址
http://dev.mysql.com/downloads/
下载页面
按照官方的文档进行安装
http://dev.mysql.com/doc/refman/5.7/en/installing.html
http://dev.mysql.com/doc/refman/5.7/en/linux-installation.html
文档地址:http://dev.mysql.com/doc/refman/5.7/en/linux-installation.html
3是各种安装方式列表
CentOS用yum安装相对省事,省去很多配置环节
yum安装,先要搞到源
wget http://repo.mysql.com/mysql57-community-release-el7-9.noarch.rpm sudo rpm -ivh mysql57-community-release-el7-9.noarch.rpm
接下来使用yum安装
更新yum软件包
yum check-update
更新系统
yum update
安装mysql
yum install mysql mysql-server
接下来是漫长的等待。如果中途关机,或者下载挂了,请执行卸载步骤后,再来一次。
完成后
记住要给root上密码
/usr/local/mysql/bin/mysqld_safe --skip-grant-tables --user=mysql & systemctl start mysqld mysql -u root mysql> update mysql.user set authentication_string=password('new_password') where user='root' and Host ='localhost'; mysql> flush privileges; mysql> quit;
启动与开放远程访问
systemctl start mysqld mysql -u root -p + 授权远程访问 use mysql; grant all privileges on *.* to root@'%' identified by "root"; FLUSH RIVILEGES;
建议root不要授权远程访问,请创建新mysql用户
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
解决如下:
1: SET PASSWORD = PASSWORD('123456@Qpf');
2:ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
3:flush privileges;
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
Fei joe 清华同衡thupdi
共同学习,写下你的评论
评论加载中...
作者其他优质文章