卸载系统自带的Mariadb
打开Terminal终端:
[root@localhost ~]# rpm -qa|grep mariadb // 查询出来已安装的mariadb
[root@localhost ~]# rpm -e --nodeps 文件名 // 卸载mariadb,文件名为上述命令查询出来的文件
Step1: 检测系统是否自带安装mysql
#yum list installed | grep mysql
Step2: 删除系统自带的mysql及其依赖 命令:
# yum -y remove mysql-libs.x86_64
Step3: 给CentOS添加rpm源,并且选择较新的源 命令:
#wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
#yum localinstall mysql-community-release-el6-5.noarch.rpm
# yum repolist all | grep mysql
# yum-config-manager --disable mysql55-community
# yum-config-manager --disable mysql56-community
# yum-config-manager --enable mysql57-community-dmr
# yum repolist enabled | grep mysql
Step4:安装mysql 服务器 命令:
# yum install mysql-community-server
yum -y install mysql-community-server
如报如下错误:
[plain] view plain copy print?在CODE上查看代码片派生到我的代码片
--> Finished Dependency Resolution
Error: Package: 2:postfix-2.10.1-6.el7.x86_64 (@anaconda)
Requires: libmysqlclient.so.18()(64bit)
Removing: 1:mariadb-libs-5.5.44-2.el7.centos.x86_64 (@anaconda)
libmysqlclient.so.18()(64bit)
Obsoleted By: mysql-community-libs-5.7.16-1.el6.x86_64 (mysql57-community)
~libmysqlclient.so.20()(64bit)
Updated By: 1:mariadb-libs-5.5.50-1.el7_2.x86_64 (updates)
libmysqlclient.so.18()(64bit)
Available: 1:mariadb-libs-5.5.47-1.el7_2.x86_64 (updates)
libmysqlclient.so.18()(64bit)
Error: Package: 2:postfix-2.10.1-6.el7.x86_64 (@anaconda)
Requires: libmysqlclient.so.18(libmysqlclient_18)(64bit)
Removing: 1:mariadb-libs-5.5.44-2.el7.centos.x86_64 (@anaconda)
libmysqlclient.so.18(libmysqlclient_18)(64bit)
Obsoleted By: mysql-community-libs-5.7.16-1.el6.x86_64 (mysql57-community)
Not found
Updated By: 1:mariadb-libs-5.5.50-1.el7_2.x86_64 (updates)
libmysqlclient.so.18(libmysqlclient_18)(64bit)
Available: 1:mariadb-libs-5.5.47-1.el7_2.x86_64 (updates)
libmysqlclient.so.18(libmysqlclient_18)(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
包依赖兼容问题,先删除mysql依赖
yum remove mysql-libs
再安装.
Step5: 启动mysql 命令:
#service mysqld start
Step6: 查看mysql是否自启动,并且设置开启自启动 命令:
# chkconfig --list | grep mysqld
# chkconfig mysqld on
Step7: mysql安全设置 命令:
# mysql_secure_installation
今天在安装mysql5.7.8的时候遇到一些问题,首当其冲便的是初始root密码的变更,特分享解决方法如下:
1.mysql5.7会生成一个初始化密码,而在之前的版本首次登陆不需要登录。
shell> cat /root/.mysql_secret
# Password set for user ‘root@localhost‘ at 2015-04-22 22:13:23
?G5W&tz1z.cN
2.若第一步成功,则使用该密码继续第7步(笔者由于找不到该文件,只能从第3步开始)
3.修改MySQL的配置文件(默认为/etc/my.cnf),在[mysqld]下添加一行skip-grant-tables
4.service mysqld restart后,即可直接用mysql进入
5.mysql> update mysql.user set authentication_string=password('Zx123qweUU') where user='root' and Host = 'localhost';
mysql> flush privileges;
mysql> quit;
6.将/etc/my.cnf文件还原,重新启动mysql:service mysqld restart,这个时候可以使用mysql -u root -p‘123qwe‘进入了
7.mysql>SET PASSWORD = PASSWORD('Zx12^yyqweUi'); 设置新密码
mysql -h localhost -u root -p
update mysql.user set password=password('www761') where user='root' and Host = 'localhost';
flush privileges;
select user,host,password from mysql.user;