Linux(CentOS 7)中安裝mysql-5.5.62


1,下載

https://dev.mysql.com/downloads/mysql/5.5.html

注意:Select Operating System: Red Hat Enterprise Linux / Oracle Linux

例如:MySQL-server-5.5.62-1.el7.x86_64.rpm

MySQL-client-5.5.62-1.el7.x86_64.rpm

2,安裝 (這里的安裝操作時基於SecureCRT工具完成的)

1,把下載好的MySQL-server-5.5.62-1.el7.x86_64.rpm 和 MySQL-client-5.5.62-1.el7.x86_64.rpm 直接拖進/opt目錄下。
2,rpm -ivh MySQL-server-5.5.62-1.el7.x86_64.rpm
3,rpm -ivh MySQL-client-5.5.62-1.el7.x86_64.rpm
4,添加mysql用戶和用戶組

1,useradd mysql

2,groupadd mysql

5,查看安裝是否成功

mysqladmin --version

mysqladmin Ver 9.0 Distrib 5.5.64-MariaDB, for Linux on x86_64 ------> 表示安裝成功

6,啟動mysql

systemctl start mysql.service

Failed to start mysql.service: Unit not found. --------> 出現問題不要着急

7,解決上面問題

在CentOS7中已經不在支持mysql,就算你已經安裝了,CentOS7還是表示很嫌棄

yum install -y mariadb-server

Transaction check error: -------> 執行上面命令,出現這個問題,說明版本沖突,仔細查看上面顯示的問題

rpm -e 出現問題的版本 -------> 刪除出現問題的版本

例如:rpm -e MySQL-client-5.5.62-1.el7.x86_64.rpm

再次執行 yum install -y mariadb-server

8,開啟mysql服務

systemctl start mariadb.service

可能會出現 ---------> Job for mariadb.service failed because the control process exited with error code. See “systemctl status mariadb.service” and “journalctl -xe” for details.

解決問題:cp /usr/share/mysql/my-huge.cnf /etc/my.cnf

3,為mysql設置密碼

/usr/bin/mysqladmin -u root password 123

登陸mysql

mysql -u root -p

Enter password: 123

顯示如下登陸成功:

Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 7 Server version: 5.5.64-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

4,設置mysql開機自動啟動

systemctl enable mariadb.service

5,解決數據中文亂碼問題

首先將mysql的配置文件my-huge.cnf復制到/etc下

cp /usr/share/mysql/my-huge.cnf /etc/my.cnf

在/etc/my.cnf/ 下添加如下代碼:

[client]

default-character-set=utf8

[mysqld]

character_set_server=utf8 character_set_client=utf8 collation-server=utf8_general_ci

[mysql]

default-character-set=utf8


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM