centOS 6.5上安装mysql5.7压缩版

mysql-5.7.10-linux-glibc2.5-i686.tar.gz是目前最新版,二进制发布包,适合各种32为版本的发型版Linux,由于只有一个包,解压后配配就行,很方便,比较符合我的风格。

 

环境:centos6.6 x86

 

1、下载 http://dev.mysql.com/downloads/mysql/

http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.10-linux-glibc2.5-i686.tar.gz

迅雷下载后ftp传到Linux下面/usr/local/soft/

2、解压缩到/usr/local/下面,mysql的主目录命名为mysql

[root@localhost local]# cd /usr/local/soft/

[root@localhost soft]# tar zvxf mysql-5.7.10-linux-glibc2.5-i686.tar.gz -C /usr/local

[root@localhost soft]# cd ..

[root@localhost local]# mv mysql-5.7.10-linux-glibc2.5-i686/ mysql

 

 

3、在mysql下面创建data数据库文件目录

[root@localhost local]# mkdir mysql/data

 

 

4、创建mysql的用户组和用户,并对mysql目录设置用户组和用户

[root@localhost local]# groupadd mysql

[root@localhost local]# useradd mysql -g mysql

[root@localhost local]# cd mysql

[root@localhost mysql]# pwd

/usr/local/mysql

[root@localhost mysql]# chown -R mysql .

[root@localhost mysql]# chgrp -R mysql .

 

5.配置my.cnf文件

[mysqld]
#忽略密码进入,这里只有Linux系统有用
skip-grant-tables
basedir=/usr/local/mysql/mysql-5.7.19
datadir=/usr/local/mysql/mysql-5.7.19/data
socket=/var/lib/mysql/mysql.sock
user=mysql
port=3306
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
#是指不区分大小写 0-区分 1-不区分
lower_case_table_names=1
max_connections=1000
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
 
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
~

注意⚠️:在window系统忽略密码不能写在配置文件中 需要在cmd中执行 mysqld --console --skip-grant-tables

 
6.安装数据库
切换到mysql安装目录
cd /usr/local/mysql/mysql-5.7.19   
执行安装脚本
./bin/mysqld --user=mysql --basedir=/usr/local/mysql/mysql-5.7.19 --datadir=/usr/local/mysql/mysql-5.7.19/data --initialize
 
7.启动服务
./bin/mysqld

8.连接进入数据库

其中指定MySQL的sock文件,通过-S指定
./bin/mysql -uroot -p -S/var/lib/mysql/mysql.sock

9.连接数据库完成,修改root用户密码

mysql>use mysql;
-- 查看user表结构,找到密码字段 authentication_string
mysql>desc user;
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
| Field                  | Type                              | Null | Key | Default               | Extra |
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
| Host                   | char(60)                          | NO   | PRI |                       |       |
| User                   | char(32)                          | NO   | PRI |                       |       |
| Select_priv            | enum('N','Y')                     | NO   |     | N                     |       |
| Insert_priv            | enum('N','Y')                     | NO   |     | N                     |       |
| Update_priv            | enum('N','Y')                     | NO   |     | N                     |       |
| Delete_priv            | enum('N','Y')                     | NO   |     | N                     |       |
| Create_priv            | enum('N','Y')                     | NO   |     | N                     |       |
| Drop_priv              | enum('N','Y')                     | NO   |     | N                     |       |
| Reload_priv            | enum('N','Y')                     | NO   |     | N                     |       |
| Shutdown_priv          | enum('N','Y')                     | NO   |     | N                     |       |
| Process_priv           | enum('N','Y')                     | NO   |     | N                     |       |
| File_priv              | enum('N','Y')                     | NO   |     | N                     |       |
| Grant_priv             | enum('N','Y')                     | NO   |     | N                     |       |
| References_priv        | enum('N','Y')                     | NO   |     | N                     |       |
| Index_priv             | enum('N','Y')                     | NO   |     | N                     |       |
| Alter_priv             | enum('N','Y')                     | NO   |     | N                     |       |
| Show_db_priv           | enum('N','Y')                     | NO   |     | N                     |       |
| Super_priv             | enum('N','Y')                     | NO   |     | N                     |       |
| Create_tmp_table_priv  | enum('N','Y')                     | NO   |     | N                     |       |
| Lock_tables_priv       | enum('N','Y')                     | NO   |     | N                     |       |
| Execute_priv           | enum('N','Y')                     | NO   |     | N                     |       |
| Repl_slave_priv        | enum('N','Y')                     | NO   |     | N                     |       |
| Repl_client_priv       | enum('N','Y')                     | NO   |     | N                     |       |
| Create_view_priv       | enum('N','Y')                     | NO   |     | N                     |       |
| Show_view_priv         | enum('N','Y')                     | NO   |     | N                     |       |
| Create_routine_priv    | enum('N','Y')                     | NO   |     | N                     |       |
| Alter_routine_priv     | enum('N','Y')                     | NO   |     | N                     |       |
| Create_user_priv       | enum('N','Y')                     | NO   |     | N                     |       |
| Event_priv             | enum('N','Y')                     | NO   |     | N                     |       |
| Trigger_priv           | enum('N','Y')                     | NO   |     | N                     |       |
| Create_tablespace_priv | enum('N','Y')                     | NO   |     | N                     |       |
| ssl_type               | enum('','ANY','X509','SPECIFIED') | NO   |     |                       |       |
| ssl_cipher             | blob                              | NO   |     | NULL                  |       |
| x509_issuer            | blob                              | NO   |     | NULL                  |       |
| x509_subject           | blob                              | NO   |     | NULL                  |       |
| max_questions          | int(11) unsigned                  | NO   |     | 0                     |       |
| max_updates            | int(11) unsigned                  | NO   |     | 0                     |       |
| max_connections        | int(11) unsigned                  | NO   |     | 0                     |       |
| max_user_connections   | int(11) unsigned                  | NO   |     | 0                     |       |
| plugin                 | char(64)                          | NO   |     | mysql_native_password |       |
| authentication_string  | text                              | YES  |     | NULL                  |       |
| password_expired       | enum('N','Y')                     | NO   |     | N                     |       |
| password_last_changed  | timestamp                         | YES  |     | NULL                  |       |
| password_lifetime      | smallint(5) unsigned              | YES  |     | NULL                  |       |
| account_locked         | enum('N','Y')                     | NO   |     | N                     |       |
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
45 rows in set (0.01 sec)
mysql>update user set authentication_string=password('root') where user='root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1
-- 刷新缓存,立即生效
mysql>flush privileges;
Query OK, 0 rows affected (0.00 sec)
 
-- 创建用户,允许外网访问
mysql>create user 'test'@'%' identified by '123456';  
mysql>flush privileges; 
Query OK, 0 rows affected (0.00 sec)
 
-- 给用户赋予权限
mysql>grant all privileges on *.* to joe@localhost identified by '1';
mysql>flush privileges;
Query OK, 0 rows affected (0.00 sec)
 
10.到目前为止配置完成。
11.问题解答。
    (1)问题:ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
                解答:  SET PASSWORD = PASSWORD('新密码');      --问题解决了
posted @ 2018-02-23 10:53  杜子腾'blog  阅读(1727)  评论(0编辑  收藏  举报