溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Linux中MySQL怎么用

發(fā)布時(shí)間:2022-01-14 15:44:12 來源:億速云 閱讀:134 作者:小新 欄目:大數(shù)據(jù)

這篇文章將為大家詳細(xì)講解有關(guān)Linux中MySQL怎么用,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

1.show databases;Linux中MySQL怎么用


2.use mysql轉(zhuǎn)換databaseLinux中MySQL怎么用


3.show tables 顯示數(shù)據(jù)庫里的表Linux中MySQL怎么用


4.select user,host,password from user查詢我的數(shù)據(jù)庫mysql的user,host,passwordLinux中MySQL怎么用


5.給賬號設(shè)置密碼
mysql> update user set password=password('123456') where user='root';Linux中MySQL怎么用


6.清除空用戶
delete From user where user='' ;Linux中MySQL怎么用


7.查看剩余用戶
Linux中MySQL怎么用命令與上文相同的查詢用戶命令 

8.刷新權(quán)限(重點(diǎn))
命令flush privileges;Linux中MySQL怎么用每次操作結(jié)束后都要刷新權(quán)限??!


9.通過用戶進(jìn)入數(shù)據(jù)庫
mysql -u root -p123456; (-p后全是密碼)Linux中MySQL怎么用



10.編輯.bash_profile文件(此步驟是為了可以讓我們使用which mysql直接找到mysql文件在哪)
vi 。bash_profile修改為# .bash_profile
 

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi


# User specific environment and startup programs


PATH=$PATH:$HOME/bin
                                     1,1           Top
# .bash_profile


# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi


# User specific environment and startup programs

export MYSQL_BASE=/usr/local/mysql
export PATH=${MYSQL_BASE}/bin:$PATH

PS1=`uname -n`":"'$USER'":"'$PWD'":>"; export PS1得到結(jié)果Linux中MySQL怎么用


11.創(chuàng)建一個(gè)新的數(shù)據(jù)庫并且設(shè)定可以進(jìn)入他的機(jī)器
11.1 create database ruozedb;創(chuàng)建數(shù)據(jù)庫ruozedb
11.2grant all privileges on ruozedb.* to ruoze@'192.168.137.252' identified by '123456'設(shè)定可以進(jìn)入數(shù)據(jù)庫ruozedb的用戶只有IP為192.168.137.252的用戶名叫做ruoze且密碼為123456(如果把IP地址改為%則表示任意ID都可以用ruoze用戶進(jìn)入)
11.3flush privileges;權(quán)限刷新
實(shí)踐如圖:Linux中MySQL怎么用


12.連接Dbeaver

Linux中MySQL怎么用


關(guān)于“Linux中MySQL怎么用”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯(cuò),請把它分享出去讓更多的人看到。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI