centos6.10 install mysql5.7

Tips: Pay attention to the version of your centos (linux system), download i686 for x32, download x86_x64 for x64. Although it may not be a problem, but just in case.

wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.31-1.el6.i686.rpm-bundle.tar 

// 解压
tar -xvf mysql-5.7.24-1.el6.x86_64.rpm-bundle.tar
 
// 安装工具包以及兼容性相关包
rpm -ivh mysql-community-common-5.7.24-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.24-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.24-1.el6.x86_64.rpm
 
// 安装mysql服务端
rpm -ivh mysql-community-server-5.7.24-1.el6.x86_64.rpm
 
// 安装mysql客户端
rpm -ivh mysql-community-client-5.7.24-1.el6.x86_64.rpm
 
// 启动mysql
service mysqld start
//如果显示[OK],就成功了,否则确认是否拼写错误。**注意是‘mysqld’不是mysql**(落泪,我这里搞错了卡了好久)
[hitony ~]# rpm -q mysql 查询发现mysql已经正常安装 ,注意此处最好用全称,否则可能查不出来。
mysql-5.1.52-jason.1

[hitony ~]# /etc/rc.d/init.d/mysqld start 直接启动没问题
Starting mysqld: [ OK ]


[hitony ~]# ls /etc/rc.d/init.d/mysqld -l
-rwxr-xr-x 1 root root 5509 Dec 18 02:31 /etc/rc.d/init.d/mysqld

[hitony ~]# chkconfig mysqld on 设置mysql开机启动

[hitony ~]# chmod 755 /etc/rc.d/init.d/mysqld 修改mysqld执行权限

[hitony ~]# service mysqld start 搞定
Starting mysqld: [ OK ]
[hitony ~]# service mysqld start
Starting mysqld: [ OK ]
[hitony ~]# service mysqld status
mysqld (pid 9487) is running...

Sample picture: (actual operation)
Find mysql
result

  • Modifications and other settings
    Sometimes the my-default.cnf file cannot be found. I found that the file directory /usr/share/mysql does not contain the'.cnf' file, which is very scary. But if you choose the right version according to the steps, you should not have this problem. I have no solution to this , nor did I find a suitable one on the Internet. (Kneeling)
    I have no similar problems here, so skip it. If there is a big guy who knows the trouble and tell me in the comments, it will be uncomfortable if you don't know how to solve it. Here is the content of my.cnf, consider creating a file with the same name instead.
    my.cnf file content

  • Change the password (you can change it by viewing the password, here is a way
    to change without a password) reference:

    	// 修改配置文件/etc/my.cnf,最后一行加上
    	lower_case_table_names=1  #表名不区分大小写
    	// 添加一句话skip-grant-tables到[mysqld]的后面一行。免密登录。
    	mysql -uroot -p // 换行即可登录,不需要密码
    	// 使用mysql自带的mysql数据库。
    	use mysql;
    	// 更改user表下的密码。
    	UPDATE user SET authentication_string = password ( '自己的密码' ) WHERE User = 'root';
    	// 刷新权限
    	flush privileges;
    	// 退出
    	quit;
    	//进入my.cnf删除skip-grant-tables
    	// 由于mysql5.7有弱密码限制,可以在配置文件中加上下面内容,关闭限制
    	validate_password=off
    

    Insert picture description here

  • Operate it to try to
    solve the permission problem (reference)
    View database

  • Modify the character set
    View:
    View
    I modified it like this:
    After the character set is modified

Reference modification:

```sql
// 在my.cnf里加入character-set-server=utf8 
character-set-server=utf8 
# 再在mysql下运行语句
# 修改character_set_connection、character_set_client、character_set_results三值
set names utf8
```

The final my.cnf file should look like this:

Insert picture description here


Zhuang Zhouxiao dreams of butterflies, and Wang Dichun cares for the cuckoo. ——Li Shangyin

Guess you like

Origin blog.csdn.net/weixin_37627774/article/details/107659114