[root@iZ23ugo7jxaZ opt]# rpm -qa | grep mysql
mysql-libs-5.1.73-3.el6_5.x86_64
[root@iZ23ugo7jxaZ opt]# rpm -e mysql-libs-5.1.73-3.el6_5.x86_64 --nodeps
[root@iZ23ugo7jxaZ opt]# rpm -qa | grep mysql[root@iZ23ugo7jxaZ opt]# cat /etc/group | grep mysql[root@iZ23ugo7jxaZ opt]# cat /etc/passwd | grep mysql[root@iZ23ugo7jxaZ opt]# groupadd mysql
[root@iZ23ugo7jxaZ opt]# cat /etc/group | grep mysql
mysql:x:500:
[root@iZ23ugo7jxaZ opt]# useradd -r -g mysql mysql
[root@iZ23ugo7jxaZ mysql3306]# cd /usr/local/mysql3306[root@iZ23ugo7jxaZ mysql3306]# cp support-files/my-default.cnf ./my.cnf[root@iZ23ugo7jxaZ mysql3306]# vi my.cnf# For advice on how to change settings please see# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the# *** default location during install, and will be replaced if you# *** upgrade to a newer version of MySQL.[client]port=3306[mysql]default-character-set=utf8[mysqld]# Remove leading # and set to the amount of RAM for the most important data# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging# changes to the binary log between backups.# log_bin=mysql-bin
# These are commonly set, remove the # and set as required.basedir = /usr/local/mysql3306datadir = /usr/local/mysql3306/dataport = 3306server_id = 1socket =/tmp/mysqld3306.sock
[root@iZ23ugo7jxaZ mysql3306]# cd /usr/local
[root@iZ23ugo7jxaZ local]# ls
aegis bin etc games include lib lib64 libexec mysql3306 sbin share src
[root@iZ23ugo7jxaZ local]# chown -Rf mysql:mysql mysql3306
[root@iZ23ugo7jxaZ local]# cd mysql3306
[root@iZ23ugo7jxaZ mysql3306]# ls
bin COPYING docs include lib man my.cnf README share support-files
[root@iZ23ugo7jxaZ mysql3306]# bin/mysqld --defaults-file=/usr/local/mysql3306/my.cnf --initialize-insecure --user=mysql
如果碰到以下错误:
bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解决问题
yum install libaio*
[root@iZ23ugo7jxaZ mysql3306]# cd support-files/
[root@iZ23ugo7jxaZ support-files]# ls
magic my-default.cnf mysqld_multi.server mysql-log-rotate mysql.server
[root@iZ23ugo7jxaZ support-files]# cp mysql.server /etc/init.d/mysqld3306[root@iZ23ugo7jxaZ support-files]# vi /etc/init.d/mysqld3306
# If you change base dir, you must also change datadir. These may get
# overwritten by settings in the MySQL configuration files.
basedir=/usr/local/mysql3306
datadir=/usr/local/mysql3306/data删除centos系统自身的my.cnf
[root@iZ23ugo7jxaZ mysql3306]# cd /etc/
[root@iZ23ugo7jxaZ etc]# rm -rf my.cnf
[root@iZ23ugo7jxaZ etc]# /etc/init.d/mysqld3306 start
Starting MySQL.[ OK[root@iZ23ugo7jxaZ etc]# chkconfig --level 35 mysqld3306 on
[root@iZ23ugo7jxaZ mysql3306]# bin/mysql -S /tmp/mysqld3306.sock
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.14 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> grant all privileges on *.* to 'root'@'%' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changedmysql> update user set authentication_string=PASSWORD("123456")where user="root";
Query OK, 2 rows affected, 1 warning (0.00 sec)
Rows matched: 2 Changed: 2 Warnings: 1
mysql> flush privileges;mysql> exit