linux安裝mysql

來源:互聯網
上載者:User

標籤:user   sql命令   href   glibc   登入   character   $path   star   chown   

1、安裝 wget 命令

yum -y install wget

 

2、也可以直接複製64位的,通過命令下載:wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz

 

3、

解壓tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz複製解壓後的mysql目錄cp -r mysql-5.6.33-linux-glibc2.5-x86_64 /usr/local/mysql

4、

1234 #添加使用者組groupadd mysql#添加使用者mysql 到使用者組mysqluseradd -g mysql mysql

 

5、安裝

123456789101112131415161718192021222324252627282930 cd /usr/local/mysql/<br>mkdir ./data/mysqlchown -R mysql:mysql ././scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysqlcp support-files/mysql.server /etc/init.d/mysqldchmod 755 /etc/init.d/mysqldcp support-files/my-default.cnf /etc/my.cnf #修改啟動指令碼vi /etc/init.d/mysqld #修改項:basedir=/usr/local/mysql/datadir=/usr/local/mysql/data/mysql #啟動服務service mysqld start #測試連接./mysql/bin/mysql -uroot #加入環境變數,編輯 /etc/profile,這樣可以在任何地方用mysql命令了export PATH=$PATH:/usr/local/mysql//bin<br>source /etc/profile  #啟動mysqlservice mysqld start#關閉mysqlservice mysqld stop#查看運行狀態service mysqld status

6、

安裝好後由於MySQL一直在/var/lib/mysql/目錄下找/mysql.sock  

而檔案實際在/tmp/mysql.sock 下,執行下面命令

 

ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock

 

 

7、

 

#1.停止mysql資料庫

/etc/init.d/mysqld stop

 

#2.執行如下命令

mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

 

#3.使用root登入mysql資料庫

mysql -u root mysql

 

#4.更新root密碼

mysql> UPDATE user SET Password=PASSWORD(‘newpassword‘) where USER=‘root‘;

#最新版MySQL請採用如下SQL:

mysql> UPDATE user SET authentication_string=PASSWORD(‘newpassword‘) where USER=‘root‘;

 

#5.重新整理許可權 

mysql> FLUSH PRIVILEGES;(or重啟主機)

 

#6.退出mysql

mysql> quit

 

#7.使用root使用者重新登入mysql

mysql -uroot -p 

Enter password: <輸入新設的密碼newpassword>

 

 

mysql的一些基本操作:

create database db_mblog;

use db_mblog;

 

--修改為UTF-8

show variables like ‘%character%‘;

set character_set_server=utf8;

show databases;

set names utf8;--設定編碼

source /home/abc/abc.sql;--執行指令碼

show tables;

linux安裝mysql

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.