64位centos6.7安裝mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz
1. 從官網下載 mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz
# wget -c http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz
2. 建立mysql的使用者組/使用者, data目錄及其使用者目錄
# groupadd mysql
# useradd -g mysql -d /home/mysql mysql
# mkdir /home/mysql/data
3. 解壓安裝包並將解壓包裡的內容拷貝到mysql的安裝目錄/home/mysql
# tar -xzvf mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz
# cd mysql-5.7.9-linux-glibc2.5-x86_64
# mv * /home/mysql
4. 初始化mysql資料庫
# cd /home/mysql
# ./bin/mysql_install_db --user=mysql --basedir=/home/mysql --datadir=/home/mysql/data
2015-11-10 02:09:17 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2015-11-10 02:09:23 [WARNING] The bootstrap log isn't empty:
2015-11-10 02:09:23 [WARNING] 2015-11-10T10:09:18.114182Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2015-11-10T10:09:18.129343Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2015-11 -10T10:09:18.129408Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
p.s. : mysql5.7新特性:由上面可以看出, mysql_install_db
已經不再推薦使用了,建議改成 mysqld --initialize
完成例項初始化。
# ./bin/mysqld --user=mysql --basedir=/home/mysql --datadir=/home/mysql/data --initialize
改用 mysqld --initialize
後,如果 datadir 指向的目標目錄下已經有資料檔案, 會出現如下提示:
# ./mysqld --user=mysql --basedir=/home/mysql --datadir=/home/mysql/data --initialize
2016-04-08T01:46:53.153530Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-04-08T01:46:53.155856Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2016-04-08T01:46:53.155879Z 0 [ERROR] Aborting
由上可知, 我們需要清空mysql的data目錄, 執行清空命令如下:
# cd /home/mysql/data
# rm -fr *
然後重新執行初始化命令如下:
# ./bin/mysqld --user=mysql --basedir=/home/mysql --datadir=/home/mysql/data --initialize
2016-04-08T01:47:57.556677Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-04-08T01:47:59.945537Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-04-08T01:48:00.333528Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-04-08T01:48:00.434908Z 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: ece26421-fd2b-11e5-a1e3-00163e001e5c.
2016-04-08T01:48:00.440125Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-04-08T01:48:00.440904Z 1 [Note] A temporary password is generated for [email protected]: **mjT,#x_5sW
牢記上面的隨機密碼, 如上**mjT,#x_5sW
, 下面我們修改密碼時需要用到。
5. 檢測下是否能啟動mysql服務
# cd /home/mysql
# ./support-files/mysql.server start
Starting MySQL.. SUCCESS!
若改用了/home/mysql
為mysql的安裝目錄basedir, 則在啟動服務時會出現如下錯誤:
# ./support-files/mysql.server start
./support-files/mysql.server: line 276: cd: /usr/local/mysql: No such file or directory
Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)
由上面可知mysql的tar.gz安裝包的預設安裝目錄為/usr/local/mysql
, 這時候我們需要修改/support-files/mysql.server
檔案的basedir和datadir目錄路徑為我們環境所在的mysql的basedir和datadir路徑, 如下:
# vim support-files/mysql.server
--------------------------
...
basedir=/home/mysql
datadir=/home/mysql/data
...
--------------------------
# ./support-files/mysql.server start
Starting MySQL.. SUCCESS!
6. 建立軟連結
# ln -s /home/mysql/bin/mysql /usr/bin/mysql
7. 建立配置檔案
將預設生成的my.cnf備份
# mv /etc/my.cnf /etc/my.cnf.bak
進入mysql的安裝目錄支援檔案目錄
# cd /home/mysql/support-files
拷貝配置檔案模板為新的mysql配置檔案,
# cp my-default.cnf /etc/my.cnf
可按需修改新的配置檔案選項, 不修改配置選項, mysql則按預設配置引數執行.
如下是我修改配置檔案/etc/my.cnf, 設定編碼為utf8以防亂碼
# vim /etc/my.cnf
[mysqld]
basedir = /home/mysql
datadir = /home/mysql/data
character_set_server=utf8
init_connect='SET NAMES utf8'
[client]
default-character-set=utf8
8. 配置mysql服務開機自動啟動
拷貝啟動檔案到/etc/init.d/下並重命令為mysqld
# cp /home/mysql/support-files/mysql.server /etc/init.d/mysqld
增加執行許可權
# chmod 755 /etc/init.d/mysqld
檢查自啟動項列表中沒有mysqld這個,如果沒有就新增mysqld
:
# chkconfig --list mysqld
# chkconfig --add mysqld
設定MySQL在345等級自動啟動
# chkconfig --level 345 mysqld on
或用這個命令設定開機啟動:
# chkconfig mysqld on
9. mysql服務的啟動/重啟/停止
啟動mysql服務
# service mysqld start
重啟mysql服務
# service mysqld restart
停止mysql服務
# service mysqld stop
10. 初始化mysql使用者root的密碼
先將mysql服務停止
# service mysqld stop
進入mysql安裝目錄, 執行:
# cd /home/mysql
# ./bin/mysqld_safe --skip-grant-tables --skip-networking&
[1] 6225
[[email protected] mysql]# 151110 02:46:08 mysqld_safe Logging to '/home/mysql/data/localhost.localdomain.err'.
151110 02:46:08 mysqld_safe Starting mysqld daemon with databases from /home/mysql/data
另外開啟一個終端(p.s. 如果是ssh連線登入的, 另外建立一個ssh連線即可), 執行操作如下:
# mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.9 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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> use mysql;
Database changed
mysql> UPDATE user SET password=PASSWORD('123456') WHERE user='root';
ERROR 1054 (42S22): Unknown column 'password' in 'field list'
mysql> update user set authentication_string = PASSWORD('123456') where user = 'root';
Query OK, 1 row affected, 1 warning (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> \s
--------------
mysql Ver 14.14 Distrib 5.7.9, for linux-glibc2.5 (x86_64) using EditLine wrapper
Connection id: 2
Current database: mysql
Current user: [email protected]
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.9 MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /tmp/mysql.sock
Uptime: 4 min 47 sec
Threads: 1 Questions: 43 Slow queries: 0 Opens: 127 Flush tables: 1 Open tables: 122 Queries per second avg: 0.149
--------------
mysql> exit;
Bye
到此, 設定完mysql使用者root的密碼且確保mysql編碼集是utf8, 注意上面, 新版本的mysql.user表裡的密碼欄位是authentication_string
快捷鍵ctrl + c
停止# ./bin/mysqld_safe ...
命令, 重新啟動mysql服務, 用新密碼連線mysql:
# service mysqld start
Starting MySQL SUCCESS!
[[email protected] bin]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.9
Copyright (c) 2000, 2015, 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> use mysql;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql > exit;
Bye
咦?又要我改密碼, 我們通過mysqladmin來修改密碼, 先輸入原密碼, 再設定新密碼, 總算可以了吧!!!
# cd /home/mysql
# ./bin/mysqladmin -u root -p password
Enter password:
New password:
Confirm new password:
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.9 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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> 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>
或直接:
# ./bin/mysqladmin -uroot -p'**mjT,#x_5sW' password '123456'
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
其中, **mjT,#x_5sW
就是我們在使用mysqld --initialize
時牢記下的隨機密碼
11. mysql遠端授權
格式如下:
mysql> grant all [privileges] on db_name.table_name to 'username'@'host' identified by 'password';
示例如下:
mysql> grant all privileges on *.* to 'root'@'%' identified by '123456';
Query OK, 0 rows affected, 1 warning (0.04 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql>
或用
mysql> grant all on *.* to 'root'@'%' identified by '123456';
到此, 完成了mysql的安裝 及配置!!!
相關推薦
CentOs下mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz壓縮包的安裝
sorted sql mbo blog 密碼 回車 安裝mysql 下載安裝 window 之前寫過一篇mysql在windows下的安裝(猛擊這兒),linux下用的比較少,最近切換到linux服務器了,發行mysql安裝和windows下有所不同,只記錄壓縮包方式安裝,
Linux安裝mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz
花了我一天時間,我得記錄下 總體來說熟悉了之後就好安裝了,開頭不懂要怎麼配置走了不少彎路 官網下載這個,其他的可能會有問題,我開頭下載了第三個配置不成功 1.解壓mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz到/u
mysql安裝-CentOS6下解壓安裝mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz
cannot x86 sed 一次 article www. 連接 初始 fresh 刪除已經安裝版本 yum list installed mysql [root@localhost ~]# yum list installed mysql Loaded plugi
linux系統centOS 7安裝 mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
#解除安裝系統自帶的Mariadb [[email protected] local]# rpm -qa|grep mariadb mariadb-libs-5.5.52-1.el7.x86_64 [[email protected] local]# rpm -e --nodep
CentOS7下安裝mysql免安裝版(mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz)
1.從mysql官網下載二進位制安裝包(https://dev.mysql.com/downloads/mysql/) 2.檢查是否已經安裝了mysql或者是MariaDB,如果已經安裝,則先把安裝的解除安裝 [[email protected] software]#
centOS 6.5 安裝 mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
下載地址: https://dev.mysql.com/downloads/mysql/5.7.html#downloads #解除安裝系統自帶的Mariadb [[email protected] local]# rpm -qa|grep mariadb
Centos6.4 + mysql-5.6.38-linux-glibc2.12-x86_64.tar 實現mysql主從復制
ide mysql-bin log_file color log-bin mysq fig isam 直接 mysql安裝方法:http://www.cnblogs.com/lin3615/p/4376224.html 用到的是兩臺服務器 主:192.168.1.1
ubuntu 16.04下安裝 mysql-connector-c-6.1.11-linux-glibc2.12-x86_64.tar.gz
最近在玩MySQL,就想著用c語言去連結資料庫,看了網上的c語言連結資料的例子,怎麼也執行不了; 網上說要安裝一個庫,如下: 安裝:sudo apt-get install libmysqlclient-dev 不知道是不是我電腦的原因,這種裝過以後報了錯誤,好像是:mysql-com
64位centos6.7安裝mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz
1. 從官網下載 mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz # wget -c http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.9-linux-gl
centos6.5安裝mysql-advanced-5.7.9-linux-glibc2.5-x86_64.tar.gz為mysql service
首先,明確一點mysql-advanced-5.7.9-linux-glibc2.5-x86_64.tar.gz為已編譯版本,所以不需要使用使用gcc編譯。但是他依賴與libaio,系統安裝盤各大映象網站均可下載。 具體步驟如下: 1、通過wget或者本地下載
64位liunx系統安裝MySQL超詳細教程
liunx版本mysql安裝包地址:https://download.csdn.net/download/qq_38545713/10615285 第一步:上傳安裝包到liunx伺服器 下載完成後;ftp上傳到伺服器 /user/local/目錄下,這個自己
64位CentOS6.2安裝erlang及rabbitmqServer
CentOS 6.2 64bit 安裝erlang及RabbitMQ Server 1、作業系統環境(CentOS 6.2 64bit) 01.[root@leekwen ~]# cat /etc/issue 02.CentOS release 6.2 (Fin
mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz 安裝
1、下載地址:MySQL-5.6.30-Linux-glibc2.5-x86_64.tar.gz 2、檢視linux系統版本: [mysql@localhost scripts]$ uname -a Linux localhost.localdomain 2.6.32-358.e
Linux CenterOS6/rhel6安裝mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz
Linux CenterOS6/rhel6 安裝mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz http://blog.csdn.net/liu_yulong/article/details/50172499
mysql-8.0.16-linux-glibc2.12-x86_64
檢查 ali 包括 next use linux man serve user MySQL5數據庫安裝部署 準備卸載之前安裝過的版本確保之前安裝過的版本完全卸載,包括老版本使用的數據文件。檢查“/etc/my.cnf”,“/etc/
64位Linux下安裝mysql-5.7.13-linux-glibc2.5-x86_64
原文地址:http://www.cnblogs.com/gaojupeng/p/5727069.html 從官網下載 mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz 經測試, 本文還適用於如下版本: mysql-5.7.
Win10 64位 Apache 2.4+MySQL 5.7+PHP 7環境搭建
ble read def 文本編輯 x64 得到 c11 next gin 軟件版本及獲取 Apache 2.4.25 win64 | MySQL Server 5.7.17 win64 | PHP 7.0 x64 Thread Safe Apache 2.4.25 wi
CentOs6.7 安裝Mysql 5.7.21
一、安裝 1.1 檢測是否已安裝mysqlyum list installed |grep mysql 如果之前沒有安裝過mysql,但是系統仍然會為你新增一個預設的mysql包,名字一般為
python2.7安裝+mysql-window-64位安裝+python連線操作mysql教程
1.相關軟體下載地址 2.準備步驟 3.python 連線資料庫 mysql 1、MySQL資料庫要用MySQLdb模組,但Python用來連結MySQL的第三方庫M
CentOS 7 安裝MySQL 5.6遇到問題及解決方案
linux localhost not ces name 解決 info target case centos下安裝mysql真的沒有想象中那麽容易,在這裏我總結一下遇到的問題 1. ERROR 2002 (HY000): Can’t connect to loca