Linux下安裝MySQL數據庫(壓縮包方式安裝)

一、這裏我將Mysql安裝在/usr/local/mysql目錄裏面,也能夠安裝在其餘地方;mysql

mkdir /usr/local/mysql
二、下載MySQL壓縮包sql

wget http://dev.MySQL.com/get/Downloads/MySQL-5.7/mysql-5.7.11-Linux-glibc2.5-x86_64.tar.gzbootstrap

// 若是上邊的命令不行的話 可使用下邊的命令
curl -O -L http://dev.MySQL.com/get/Downloads/MySQL-5.7/mysql-5.7.11-Linux-glibc2.5-x86_64.tar.gz
三、解壓並複製curl

tar -zxvf mysql-5.7.11-Linux-glibc2.5-x86_64.tar.gz
mv mysql-5.7.11-Linux-glibc2.5-x86_64/* /usr/local/mysql/
四、建立data目錄socket

mkdir /usr/local/mysql/data
五、建立mysql用戶組及其用戶ide

groupadd mysql
useradd -r -g mysql mysql
六、初始化數據ui

複製代碼
[root@localhost mysql] ./bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
2016-01-20 02:47:35 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2016-01-20 02:47:45 [WARNING] The bootstrap log isn't empty:
2016-01-20 02:47:45 [WARNING] 2016-01-19T18:47:36.732678Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2016-01-19T18:47:36.750527Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2016-01-19T18:47:36.750560Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
複製代碼
七、複製配置文件到 /etc/my.cnfurl

cp -a ./support-files/my-default.cnf /etc/my.cnf (選擇y)
八、MySQL的服務腳本放到系統服務中orm

複製代碼
cp -a ./support-files/mysql.server /etc/init.d/mysqld
修改my.cnf文件server

These are commonly set, remove the # and set as required.

basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306

server_id = .....

socket = /tmp/mysql.sock
character-set-server = utf8

Remove leading # to set options mainly useful for reporting servers.

The server defaults are faster for transactions and fast SELECTs.

Adjust sizes as needed, experiment to find the optimal values.

join_buffer_size = 128M

sort_buffer_size = 2M

read_rnd_buffer_size = 2M

複製代碼
九、建立In

ln -s /usr/local/mysql/ /usr/bin/
十、啓動服務

service mysqld start
十一、初始化密碼

mysql5.7會生成一個初始化密碼,在root中.mysql_secret文件中。

[root@localhost ~]# cat /root/.mysql_secret

Password set for user 'root@localhost' at 2017-03-16 00:52:34

ws;fmT7yh0CM
十二、登陸並修改密碼

[root@localhost ~]# mysql -u root -p

alter user root@localhost identified by 'tiger';

flush privileges;
1三、退出從新登陸,完成

複製代碼 mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.11 sec)

相關文章
相關標籤/搜索