1.
首先新增mysql使用者組
groupadd mysql
shell> groupadd mysql 2.
新增mysql使用者,並指定到mysql使用者組
useradd -g mysql mysql
shell> useradd -g mysql mysql 3.
解壓縮mysql-version.tar.gz到安裝目錄(/usr/local/)
cd /usr/local
gunzip < /path/to/mysql-version-os.tar.gz | tar xvf -
shell> cd /usr/local
shell> gunzip < /path/to/mysql-version-os.tar.gz | tar xvf - 4.
為建立mysql軟連線mysql-version-os
shell> ln -s full-path-to-mysql-version-os mysql
shell> cd mysql
shell> ln -s full-path-to-mysql-version-os mysql
shell> cd mysql 5.
設定mysql安裝目錄許可權,設定owner為mysql
shell> chown -r mysql .
shell> chown -r mysql . 6.
執行mysql系統資料庫初始化指令碼
shell> scripts/mysql_install_db --user=mysql
shell> scripts/mysql_install_db --user=mysql 7.
設定data目錄許可權,分配給mysql使用者,為了mysql程式能讀寫data目錄下的檔案
chown -r mysql data
shell> chown -r mysql data 8.
使用mysql帳號啟動mysql應用
bin/mysqld_safe --user=mysql &
shell> bin/mysqld_safe --user=mysql & 9.
設定root密碼
bin/mysqladmin -u root password '123123'
shell> bin/mysqladmin -u root password '123123'
10.登入mysql
bin/mysql -u root -p
enter password:
shell> bin/mysql -u root -p
enter password:
登入成功會看到:
welcome to the mysql monitor. commands end with ; or /g.
your mysql connection id is 229
server version: 5.1.40-log mysql community server (gpl)
type 'help;' or '/h' for help. type '/c' to clear the current input statement.
mysql>
welcome to the mysql monitor.commands end with ; or /g.
your mysql connection id is 229
server version: 5.1.40-log mysql community server (gpl)
type 'help;' or '/h' for help. type '/c' to clear the current input statement.
mysql>
這時mysql已經裝好了,可以檢視資料庫了,但在正式使用資料庫開發與部署的時候還需要做一些工作:
1.設定配置檔案my.cnf
按照需求copy my-***.cnf到/etc/my.cnf
2.修改預設字符集utf8
(1).[client]下加入default-character-set=utf8
(2).[mysqld]下加入default-character-set=utf8
3.設定預設儲存引擎
mysql for linux的版本預設使用的資料庫引擎是myisam,但只有innodb引擎支援事務,
所以需要修改配置:
(1).[mysqld]下加入default-storage-engine=innodb
4.配置innodb引數
(1).找到# uncomment the following if you are using innodb tables
去掉innodb_*下的所有#
(2).如果安裝mysql的目錄不是預設的,則需要修改
# mysql 預設安裝目錄為/usr/local/mysql/
# mysql 預設表空間目錄安裝目錄為/usr/local/mysql/data/
innodb_data_home_dir=/usr/local/database/mysql/data/
innodb_log_group_home_dir=/usr/local/database/mysql/data/
5.設定系統服務
讓linux啟動的時候就啟動mysql服務
shell> cd /usr/local/mysql/
shell> cp support-files/mysql.server /etc/init.d/mysql
shell> chmod 777 /etc/init.d/mysql
shell> chkconfig --add mysql
shell> chkconfig --level 35 mysql on
shell> cd /usr/local/mysql/
shell> cp support-files/mysql.server /etc/init.d/mysql
shell> chmod 777 /etc/init.d/mysql
shell> chkconfig --add mysql
shell> chkconfig --level 35 mysql on 6.
重啟mysql服務
shell> service mysql restart
詳解Mysql安裝教程
這裡以5.7.20版本為例 1 首先安裝包解壓後,沒有網上教程裡面提到的data資料夾和my default.ini,如下圖所示 2 配置環境變數 即在環境變數中path中加入mysql解壓包bin所在路徑,我的是 d softnew mysql mysql 5.7.20 winx64 bin 主要...
mysql多例項安裝詳解
首先說明乙個場景 我的電腦是 ubuntu系統 之前apt get自動安裝過mysql。這也是出現錯誤最多的原因之一。安裝過程,其中充斥著各種錯誤 6.mkdir mysql 7.groupadd mysql 8.useradd r g mysql mysql make clean rm f cma...
mysql怎麼安裝索引 MySQL 索引詳解
6.索引的長度 在為char和varchar型別的資料列定義索引時,可以把索引的長度限制為乙個給定的字元個數 這個數字必須小於這個欄位所允許的最大字元個數 這麼做的好處是可以生成乙個尺寸比較小 檢索速度卻比較快的索引檔案。在絕大多數應用裡,資料庫中的字串資料大都以各種各樣的名字為主,把索引的長度設定...