目錄
3.9.1執行如果出現錯誤,可能缺少這個依賴:yum install libaio
3.10、修改Mysql配置文件,並將配置文件放到/etc/init.d/目錄下面
3.10.1將當前配置文件加入到啓動/etc/init.d/mysqld
3.11、加入開啓自啓動,啓動mysql。(這個用不用都行)
14.1 如果不只是在 /usr/local/mysql路徑下面可能會報錯,那麼執行下面操作,軟連接
1、常用命令總結
1.rpm卸載: rpm -e --nodeps mysql-community-common-8.0.19-1.el7.x86_64
rpm查找: rpm -qa | grep mariadb
2.yum卸載:yum remove xx
3.服務重啓操作命令:systemctl restart mysqld
查看狀態: systemctl status mysqld
centos6.5mysql的服務操作命令:service mysql start/stop
4.關閉防火牆 :systemctl stop firewalld.service
開機禁止啓動防火牆:systemctl disable firewalld.service
2、rpm下載安裝(最快捷方式)
2.1、卸載mariadb
2.2、安裝依賴
具體根據實際情況,缺啥安裝啥,這個也沒細總結過
2.3、下載rpm文件
2.3.1下載地址
2.3.2下載整合版Bundle
2.3.3下載四個文件
下載地址是:
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-server-5.7.30-1.el7.x86_64.rpm
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-server-5.7.30-1.el7.x86_64.rpm
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-common-5.7.30-1.el7.x86_64.rpm
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-libs-5.7.30-1.el7.x86_64.rpm
2.4、執行命令安裝
sudo rpm -ivh mysql-community-common-5.7.30-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-libs-5.7.30-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-client-5.7.30-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-server-5.7.30-1.el7.x86_64.rpm
2.5、安裝目錄如下
2.6、查看mysql運行狀態,並重啓
2.7、重置密碼
3、tar安裝
卸載:mariadb
3.1、下載安裝包
3.2、上傳到服務器
3.3、解壓到當前文件夾/usr/local/
3.4、創建data路徑
3.5、創建mysql用戶組
3.6、授權用戶組
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/data
3.7、初始化腳本,5.7中 這個過時了(這裏不採用)
/usr/local/mysql/bin/mysql_install_db --user=mysql
[root@ip-100 bin]# /usr/local/mysql/bin/mysql_install_db --user=mysql
2020-01-16 01:23:59 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2020-01-16 01:23:59 [ERROR] The data directory needs to be specified.
3.8、更改mysql安裝文件夾mysql/的權限
3.9、初始化mysql
3.9.1執行如果出現錯誤,可能缺少這個依賴:yum install libaio
2020-01-15T17:31:36.283878Z 1 [Note] A temporary password is generated for root@localhost: spPwujtd1z%X
[root@ip-100 mysql]# /usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
2020-01-15T17:31:33.818233Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-01-15T17:31:34.417755Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-01-15T17:31:34.510250Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-01-15T17:31:34.759518Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: e0788195-37bc-11ea-a2a6-000c29cf0c82.
2020-01-15T17:31:34.765729Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-01-15T17:31:35.831655Z 0 [Warning] CA certificate ca.pem is self signed.
2020-01-15T17:31:36.283878Z 1 [Note] A temporary password is generated for root@localhost: spPwujtd1z%X
3.10、修改Mysql配置文件,並將配置文件放到/etc/init.d/目錄下面
3.10.1將當前配置文件加入到啓動/etc/init.d/mysqld
3.11、加入開啓自啓動,啓動mysql。(這個用不用都行)
3.12、添加my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
3.13、mysql添加到環境變量中
3.14、啓動mysql服務
14.1 如果不只是在 /usr/local/mysql路徑下面可能會報錯,那麼執行下面操作,軟連接
Starting MySQL.Logging to '/data/mysql/SZY.err'.
2018-07-02T10:09:03.779928Z mysqld_safe The file /usr/local/mysql/bin/mysqld
does not exist or is not executable. Please cd to the mysql installation
directory and restart this script from there as follows:
./bin/mysqld_safe&
See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more information
ERROR! The server quit without updating PID file (/software/mysql/mysqld.pid).