Linux MySQL 5.6.43 安裝

【注意】node

1.首先安裝在默認目錄 /usr/local/mysql,如需更改數據存儲目錄,進行二、3兩步mysql

2.若是須要修改數據目錄,將my.nf 中的 datadir=/usr/local/mysql/data 進行修改linux

3.將 /usr/local/mysql/data 中的文件複製到修改後的目標 datadir 目錄中redis

 


【 卸載原有的】sql

 看看有沒有自帶的,有的話卸載,沒有就跳過,直接安裝數據庫

[root@localhost ~]#  rpm -qa | grep mariadb
mariadb-5.5.56-2.el7.x86_64
mariadb-libs-5.5.56-2.el7.x86_64
[root@localhost ~]# rpm -e --nodeps mariadb-5.5.56-2.el7.x86_64
[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
刪除文件夾
 
[root@localhost ~l]#find / -name mysql
 /var/lib/mysql
 /usr/lib64/mysql
[root@localhost ~l]#rm -rf /var/lib/mysql

  


【開始安裝 5.6.43 】
注意要裝在 /usr/local/mysql 目錄下,默認的就不要動它了,防止有坑。
[root@localhost ~l]# tar -zvxf mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz 
[root@localhost ~l]# mv mysql-5.6.43-linux-glibc2.12-x86_64 /usr/local/mysql
[root@localhost ~]# cd /usr/local/mysql/
[root@localhost mysql]# groupadd mysql
[root@localhost mysql]# useradd -r -g mysql mysql
[root@localhost mysql]# chown -R mysql:mysql /usr/local/mysql/

修改配置文件
[root@localhost mysql]# vi /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data #先安裝再修改
port = 3306
socket=/tmp/mysql.sock

symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/tmp/mysqld/mysqld.pid
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
log-bin=mysql-bin 
binlog-format=ROW 
server_id=1 
max_connections=1000

init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
建立配置文件中,須要的文件
[root@localhost mysql]# mkdir /tmp/mysqld [root@localhost mysql]# touch /tmp/mysqld/mysqld.pid [root@localhost mysql]# chown -R mysql:mysql /tmp/mysqld/ [root@localhost mysql]# chmod -755 /tmp/mysqld/mysqld.pid [root@localhost mysql]# touch /var/log/mysqld.log [root@localhost mysql]# chown -R mysql:mysql /var/log [root@localhost mysql]# chmod 755 /var/log/mysqld.log
初始化數據庫
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

 
[root@localhost mysql]# ./bin/mysqld_safe --user=mysql &
或者
[root@localhost mysql]# ./support-files/mysql.server start
[root@localhost ~]# ps -ef|grep mysql

 

[root@localhost mysql]# ./bin/mysqladmin -u root password '123456'
[root@localhost mysql]# ./bin/mysql -uroot -p123456 

容許遠程訪問:
mysql> grant all privileges on *.* to 'root'@'%'identified by '123456' with grant option;
mysql> flush privileges;

也能夠登陸後改密碼:
mysql>update mysql.user set password=password('root') where user='root'; flush privileges;tomcat

  


【自啓動】 
[root@localhost ~]# vi /etc/rc.d/rc.local 
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

#touch /var/lock/subsys/local


echo "rc.d/rc.local start running "$(date+%Y%m%d) >> /tmp/redis.log
/usr/local/iron/redis/redis.sh >> /tmp/redis.log
/usr/local/iron/tomcat8085/bin/startup.sh >> /tmp/tomcat.log
/usr/local/mysql/support-files/mysql.server start
相關文章
相關標籤/搜索