rpm -qa | grep mysql
rpm -e --nodeps ‘上一步查找的名称
[root@localhost ~]#whereis mysql
mysql: /usr/bin/mysql /usr/local/mysql
[root@localhost ~]# find / -name mysql
/run/lock/subsys/mysql
/etc/rc.d/init.d/mysql
/usr/bin/mysql
/usr/local/mysql
/usr/local/mysql/bin/mysql
/usr/local/mysql/include/mysql
/usr/local/mysql/data/mysql
rm -rf 文件路径
MySQL官网
[root@x ~]# cd /usr/local/
[root@x local]# tar -zxvf mysql-5.7.30-el7-x86_64.tar.gz
注:如果是tar包:
先 tar -xvf mysql-5.7.30-el7-x86_64.tar
再 tar -zxvf mysql-5.7.30-el7-x86_64.tar.gz
[root@x local]# mv mysql-5.7.30-el7-x86_64/ mysql
[root@x local]# mkdir mysql/data
[root@x local]# cat /etc/group | grep mysql
[root@x local]# cat /etc/passwd | grep mysql
[root@x local]# groupadd mysql
[root@x local]# useradd -r -g mysql mysql
[root@x local]# chown -R mysql:mysql /usr/local/mysql/
[root@x local]# chmod -R 755 /usr/local/mysql
[root@x local]#cd mysql/bin
./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql
[root@localhost bin]# rmp -qa|grep libaio
-bash: rmp: command not found
[root@localhost bin]# yum -y install libaio-devel.x86_64
[client]
#password = your_password
port = 3306
socket = /usr/local/mysql/data/mysql.sock
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
init_connect = 'SET NAMES utf8mb4'
port = 3306
socket = /usr/local/mysql/data/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
datadir = /usr/local/mysql/data
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
/usr/local/mysql/support-files/mysql.server start
启动命令:service mysql start
重启命令:service mysql restart
停止命令:service mysql stop
ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
ln -s /usr/local/mysql/mysql.sock /var/mysql.sock
service mysql restart
[root@x bin]# mysql -u root -p
Enter password:
mysql>set password for root@localhost = password('123456');
mysql>use mysql;
msyql>update user set user.Host='%' where user.User='root';
mysql>flush privileges; //刷新权限
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --list
注:如果看到mysql的服务,并且3,4,5都是开的话则成功,如果是关,则
chkconfig --level 345 mysqld on
reboot
查看mysql服务是否开机自启。
vi /etc/my.cnf
skip-grant-tables
/etc/init.d/mysql restart
/etc/init.d/mysqld restart
set password for root@localhost=password('123456');
set password for root@localhost=password('123456');
vi /etc/my.cnf
搞定!