您好,登錄后才能下訂單哦!
1、查看下面包是否安裝,有安裝的話卸載
# rpm -qa | grep mariadb
# rpm -qa | grep postfix
# rpm -ev postfix-2.10.1-6.el7.x86_64
# rpm -ev mariadb-libs-5.5.44-2.el7.centos.x86_64
2、創建用戶和組
# groupadd mysql
# useradd -g mysql mysql
3、解壓
# tar -zxf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
# mv mysql-5.7.17-linux-glibc2.5-x86_64 /usr/local/mysql
4、修改配置文件
# cd /usr/local/mysql/support-files
# cp my-default.cnf /etc/my.cnf
# vi /etc/my.cnf
[mysql]
default-character-set=utf8
[mysqld]
default-storage-engine=INNODB
character_set_server=utf8
pid_file=/data/mysql/mysql.pid
expire_logs_days=15
innodb_buffer_pool_size=8G
innodb_log_file_size=256M
innodb_flush_method=O_DIRECT
max_connections=500
innodb_autoextend_increment=128
basedir = /usr/local/mysql
datadir = /data/mysql/data
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
修改文件權限
# chown -R mysql:mysql /usr/local/mysql
# mkdir -p /data/mysql/data
# chown -R mysql:mysql /data
# chown 777 /etc/my.cnf
5、初始化數據庫
# cd /usr/local/mysql/bin
# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data
6、設置開機自啟動
# cp mysql.server /etc/rc.d/init.d/mysqld
# chmod +x /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
7、啟動并檢查服務
# service mysqld start
# ps -ef | grep mysql
# netstat -an | grep :3306
8、設置環境變量
vi /etc/profile
export PATH=$PATH:/usr/local/mysql/bin
source /etc/profile
9、登錄并修改密碼
# mysql -uroot -p
密碼可以查看 /root/.mysql_secret 文件
實在找不到密碼,也可以配置為跳過密碼,直接登錄,修改密碼后再改回來
具體方法如下:
# vi /etc/my.cnf
[mysqld]
skip-grant-tables
# service mysqld restart
mysql -uroot -p
mysql> update mysql.user set authentication_string=password('自定義密碼') where user='root';
mysql> grant all privileges on *.* to 'root'@'%' identified by '自定義密碼';
如果出錯:
mysql> update mysql.user set authentication_string=password('自定義密碼') where user='root';
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> SET PASSWORD = PASSWORD('自定義密碼');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。