一、下载mysql
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.11.tar.gz tar xf mysql-5.7.11.tar.gz cd mysql-5.7.11 useradd -s /sbin/nologin -M mysql
二、Configure
参数
cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/data/mysql\ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DEXTRA_CHARSETS=all \ -DENABLED_LOCAL_INFILE=1 \ -DDOWNLOAD_BOOST=1 \ -DWITH_BOOST=/usr/local/boost
三、然后编译安装
make && make install
四、初始化数据库
/usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/data/mysql --basedir=/usr/local/mysql --socket=/tmp/mysql.sock
初始化数据库之后会出现一个root密码
[Note] A temporary password is generated for root@localhost: KEDejuD>:2o5
出现以下错误是以前老版本的mysql配置文件my.cnf还没删除,--skip-locking已经被废弃了
ERROR :unknown option '--skip-locking'
五、添加mysqld
服务
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld chmod 755 /etc/init.d/mysqld chkconfig mysqld on
六、编辑my.cnf
文件
vim /etc/my.cnf
添加以下内容:
port=3306 basedir=/usr/local/mysql datadir=/data/mysql socket=/tmp/mysql.sock
七、启动mysqld
服务
/etc/init.d/mysqld start
mysql
服务启动之后,还需要修改密码
mysql -uroot -p KEDejuD>:2o5
什么也不能做,必须先改密码
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> set password=password('hello123'); Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
以前的那种模式将被遗弃
| Warning | 1287 | 'SET PASSWORD = PASSWORD('<plaintext_password>')' is deprecated and will be removed in a future release. Please use SET PASSWORD = '<plaintext_password>' instead
也就是说可以直接这样:
mysql> set password='hello123'; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
5.7.11
对密码有了更严格的要求,分为LOW
,MEDIUM
,<code class="prettyprint" >STRONG
三个等级,对应要求如下:
LOW Length >= 8 MEDIUM Length >= 8, numeric, mixed case, and special characters STRONGLength >= 8, numeric, mixed case, special characters and dictionary file
参考:
http://blog.itpub.net/27099995/viewspace-1994443/