一. 检查是否已经存在数据库rpm -qa |grep mariadb
#如果已经安装,需要卸载mariadb数据库
rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_642
二.检查是否安装了 libaio
rpm -qa | grep libaio
三.初始化
mysqld /usr/local/mysql/bin/mysqld --user=mysql
--basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data --initialize
此时会生成临时密钥:
A temporary password is generated for root@localhost: 2KTfuVxith.h
四.配置 mysql
用mysql --help | grep 'my.cnf'命令即可查看MySQL启动时读取配置文件的默认目录
vim /etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/data
basedir=/usr/local/mysql
socket=/tmp/mysql.sockuser=mysqlport=3306
character-set-server=utf8
riskssymbolic-links=0
log-error=/var/log/mysqld.
logpid-file=/var/run/mysqld/mysqld.pid
五、启动mysql
service mysql start
可能报错:
【MySQL】出现Failed to start mysql.service: Unit not found
原因
/etc/init.d中没有mysql启动项find / -name mysql.server
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqlservice mysql start
6.登录mysql /usr/local/mysql/bin/mysql -u root -p
修改用户的密码
>>use mysql (使用mysql库)
>>update mysql.user set authentication_string=password('123456') where user='root';
>>flush privileges;