标签:服务 chmod vim init list 查看 amp profile upd
[root@localhost ~]# yum -y install libaio
600多m的rpm要上传到虚拟机上
mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
[root@localhost ~]# tar xf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C /usr/local/ ##注意是local不是src
[root@localhost ~]# cd /usr/local/
[root@localhost local]# mv mysql-5.7.24-linux-glibc2.12-x86_64/ mysql
[root@localhost local]# useradd -M -s /sbin/nologin mysql
[root@localhost local]# chown -R mysql:mysql /usr/local/mysql/
[root@localhost local]# /usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize ##初始化数据库得到密码
密码为上面这个
[root@localhost local]# vim /etc/my.cnf
将mysqld服务添加到系统服务中,命令如下
[root@localhost local]# cd mysql/
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# chkconfig --add mysqld ##添加到系统服务中
[root@localhost mysql]# systemctl start mysqld
[root@localhost mysql]# netstat -anpt |grep mysqld
tcp6 0 0 :::3306 :::* LISTEN 39128/mysqld
成功开启
添加环境变量
[root@nginx mysql]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
[root@nginx mysql]# source /etc/profile
[root@localhost local]# cd mysql/
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld #复制到主配置文件就可以直接使用systemctl start mysqld
[root@localhost mysql]# chkconfig --add mysqld #也可以用chmod +x /etc/init.d/mysqld
[root@localhost mysql]# systemctl start mysqld
注意:-p后面后面没有空格 password后面有空格
-------------------------------MySQL登不上解决方法-------------------
[root@localhost ~]# systemctl stop mysqld
[root@localhost ~]# mysqld_safe --skip-grant-tables &
[root@localhost ~]# 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
标签:服务 chmod vim init list 查看 amp profile upd
原文地址:https://www.cnblogs.com/maoyanqing/p/11517214.html