centos安装mysql5.6的正确姿态

时间:2022-12-08 16:43:15

1.准备工作

查询系统默认软件mariadb

rpm -qa | grep mariadb

a)卸载centos默认软件

yum -y remove mariadb-libs

b)安装依赖包

yum install -y perl-Module-Install.noarch

2.解压rpm安装包

tar -xf MySQL-5.6.33-1.linux_glibc2.5.x86_64.rpm-bundle.tar

3.安装rpm安装包

rpm -ivh *.rpm

3.1删除rpm安装包和压缩包

rm -rf MySQL*

4.设置权限,以非root用户运行

chown -R mysql.mysql /var/lib/mysql/

5.数据库初始化

/usr/bin/mysql_install_db

6.启动Mysql
service mysql start

[root@localhost rpm]# /usr/bin/mysql_install_db
[root@localhost rpm]# service mysql start
[root@localhost rpm]# vi /root/.mysql_secret #查看root账号密码
# The random password set for the root user at Wed Dec 11 23:32:50 2013 (local time): qKTaFZnl
[root@localhost ~]# mysql -uroot –pqKTaFZnl
mysql> SET PASSWORD = PASSWORD('123456'); #设置密码为123456
mysql> exit
[root@localhost ~]# mysql -uroot -p123456