[[email protected] ~]# yum -y install libaio
600多m的rpm要上传到虚拟机上
mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
[[email protected] ~]# tar xf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C /usr/local/ ##注意是local不是src
[[email protected] ~]# cd /usr/local/
[[email protected] local]# mv mysql-5.7.24-linux-glibc2.12-x86_64/ mysql
[[email protected] local]# useradd -M -s /sbin/nologin mysql
[[email protected] local]# chown -R mysql:mysql /usr/local/mysql/
[[email protected] local]# /usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize ##初始化数据库得到密码
密码为上面这个
[[email protected] local]# vim /etc/my.cnf
将mysqld服务添加到系统服务中,命令如下
[[email protected] local]# cd mysql/
[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[[email protected] mysql]# chkconfig --add mysqld ##添加到系统服务中
[[email protected] mysql]# systemctl start mysqld
[[email protected] mysql]# netstat -anpt |grep mysqld
tcp6 0 0 :::3306 :::* LISTEN 39128/mysqld
成功开启
添加环境变量
[[email protected] mysql]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
[[email protected] mysql]# source /etc/profile
[[email protected] local]# cd mysql/
[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld #复制到主配置文件就可以直接使用systemctl start mysqld
[[email protected] mysql]# chkconfig --add mysqld #也可以用chmod x /etc/init.d/mysqld
[[email protected] mysql]# systemctl start mysqld
注意:-p后面后面没有空格 password后面有空格
-------------------------------MySQL登不上解决方法-------------------
[[email protected] ~]# systemctl stop mysqld
[[email protected] ~]# mysqld_safe --skip-grant-tables &
[[email protected] ~]# mysql #直接登录进去
mysql> show databases;
mysql> use mysql ##进入数据库
mysql> show tables; ##查看有哪些表
mysql> desc user; ##查看列表
mysql> update user set authentication_string=PASSWORD(‘123456‘) where user=‘root‘;
密码修改成功
刷新授权表
OK