linux下的mysql安裝

1.官網下載
查看linux是32位還是64位 file /bin/ls
下載mysql-5.7.17-linux-glibc2.5-x86_64.tar

2.安裝與配置

[root:/home/tmp # tar -xvf mysql-5.7.17-linux-glibc2.5-x86_64.tar

mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

mysql-test-5.7.17-linux-glibc2.5-x86_64.tar.gz

[root:/home/tmp # tar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz 

[root:/home/tmp # cd /usr/local

[root:/usr/local # mkdir mysql

[root:/usr/local # cp -rp /home/tmp/mysql .

[root:/usr/local # cd mysql/

[root:/usr/local/mysql # groupadd mysql

[root:/usr/local/mysql # useradd -g mysql mysql

[root:/usr/local # cd ..

[root:/usr/local # chown -R mysql mysql/

[root:/usr/local # chgrp -R mysql mysql/

[root:/usr/local/mysql # cd mysql/ [root:/usr/local/mysql # bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data

2017-03-17 09:34:00 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize

2017-03-17 09:34:07 [WARNING] The bootstrap log isn't empty:

2017-03-17 09:34:07 [WARNING] 2017-03-17T01:34:01.021294Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead

2017-03-17T01:34:01.022032Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)

2017-03-17T01:34:01.022039Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)

[root:/usr/local/mysql # cp -a ./support-files/my-default.cnf /etc/my.cnf 

[root:/usr/local/mysql # cp -a ./support-files/mysql.server /etc/init.d/mysqld

[root:/usr/local/mysql # cd bin

sgs1-pas1:/usr/local/mysql/bin # ./mysqld_safe --user=mysql & --安全模式

[1] 21402

sgs1-pas1:/usr/local/mysql/bin # 2017-03-17T01:35:57.584201Z mysqld_safe Logging to '/usr/local/mysql/data/sgs1-pas1.err'.

Logging to '/usr/local/mysql/data/sgs1-pas1.err'.

2017-03-17T01:35:57.677401Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data

2017-03-17T01:37:25.182204Z mysqld_safe mysqld from pid file /usr/local/mysql/data/sgs1-pas1.pid ended

[1]+  Done                    ./mysqld_safe --user=mysql

[root:/usr/local/mysql/bin #

另起一終端

[root:/usr/local/mysql/bin # /etc/init.d/mysqld restart

[root:/usr/local/mysql/bin # cat /root/.mysql_secret 

# Password set for user 'root@localhost' at 2017-03-17 09:34:01 

FSe&IrLnO:5M --隨機密碼

[root:/usr/local/mysql/bin # ./mysql -uroot -p

Enter password: 

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 5

Server version: 5.7.17

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

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

[mysql> set PASSWORD = PASSWORD('123456');

Query OK, 0 rows affected, 1 warning (0.00 sec)

[mysql> flush privileges

    -> ;

Query OK, 0 rows affected (0.00 sec)

[mysql> use mysql;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> update user set host='%' where user='root';

Query OK, 1 row affected (0.00 sec)

Rows matched: 1  Changed: 1  Warnings: 0

[mysql> select host,user from user;

+-----------+-----------+

| host      | user      |

+-----------+-----------+

| %         | root      |

| localhost | mysql.sys |

+-----------+-----------+

2 rows in set (0.00 sec)

[mysql> exit;

Bye

[root:/usr/local/mysql/bin # /etc/init.d/mysqld restart

Shutting down MySQL.. SUCCESS! 

Starting MySQL. SUCCESS! 

3.會用到的命令

rpm -qa|grep mysql 查看是否安裝mysql

whereis mysql 查找mysql

which mysql 查找mysql

MySQL在Linux下數據庫名、表名、列名、別名大小寫規則是這樣的:
  1、數據庫名與表名是嚴格區分大小寫的;
  2、表的別名是嚴格區分大小寫的;
  3、列名與列的別名在所有的情況下均是忽略大小寫的;
      4、字段內容默認情況下是大小寫不敏感的。
mysql中控制數據庫名和表名的大小寫敏感由參數lower_case_table_names控制,爲0時表示區分大小寫,爲1時,表示將名字轉化爲小寫後存儲,不區分大小寫。
mysql> show variables like '%case%';
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| lower_case_file_system | OFF   |
| lower_case_table_names | 0     |
+------------------------+-------+
2 rows in set (0.00 sec)
 
修改cnf配置文件或者編譯的時候,需要重啓服務
用root帳號登錄後,在/etc/my.cnf 中的[mysqld]後添加添加lower_case_table_names=1,重啓MYSQL服務


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章