1.安装准备:
1.1、mysql-5.7.11.tar.gz
1.2、mysql-boost-5.7.11.tar.gz
1.3、保证系统安装cmake、ncurses-devel、没有请安装。
1.1 编译:
cd /home/usench1/app_pkg/mysql-5.7.11/cmake
cmake .. -DWITH_BOOST=/home/usench1/app_pkg/mysql-5.7.11/boost -DCMAKE_INSTALL_PREFIX=/home/usench1/app/mysql -DMYSQL_DATADIR=/home/usench1/app/mysql/data -DMYSQL_KEYRINGDIR=/home/usench1/app/mysql/keyring -DTMPDIR=/home/usench1/app/mysql/temp -DDEFAULT_COLLATION=utf8_general_ci -DDEFAULT_CHARSET=utf8 -DMYSQL_UNIX_ADDR=/home/usench1/app/mysql/mysql.sock -DSYSTEMD_PID_DIR=/home/usench1/app/mysql/pid -DSYSCONFDIR=/home/usench1/app/mysql -DMYSQL_TCP_PORT=3366 -DMYSQL_USER=usench1
![](/qrcode.jpg)
1.2 make
1.3 make install
2.数据库初始化操作:
2.1 cd /home/usench1/app/mysql/support-files
cp my-default.cnf ../my.cnf
vi ../my.cnf
内容如下:
basedir = /home/usench1/app/mysql
datadir = /home/usench1/app/mysql/data
port = 3366
server_id = mysqlrap
socket = /home/usench1/app/mysql/data/mysql.sock
保存,退出。
2.1 进入到mysql安装bin目录,执行
./mysqld --initialize --user=usench1 --basedir=/home/usench1/app/mysql --datadir=/home/usench1/app/mysql/data
完成后记录下临时密码: k-Y%)b_;E1au
2.2 cd /home/usench1/app/mysql/support-files
./mysql.server start
2.3 cd /home/usench1/app/mysql/bin
./mysql -uroot -p --socket=/home/usench1/app/mysql/data/mysql.sock
2.4 修改密码,否则不能运行
ALTER USER USER() IDENTIFIED BY ‘123qwe’;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123qwe' WITH GRANT OPTION;
FLUSH PRIVILEGES;
3.忘记root密码:
关闭mysql服务:
修改MySQL的配置文件(默认为/etc/my.cnf),在[mysqld]下添加一行skip-grant-tables
重新启动mysql服务:
执行mysql 登录:
mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';
mysql>flush privileges;
将/etc/my.cnf文件还原,重新启动mysql:service mysql restart,这个时候可以使用mysql -u root -p‘123qwe‘进入了.
GRANT ALL ON tb_rap.* TO 'rap'@'%';