MySql 問題收集

2021-06-21 22:53:24 字數 1099 閱讀 2867

關鍵字: mysql 遠端連線

1.修改mysql配置檔案(/etc/mysql/my.cnf),注釋以下行:

#bind-address = 127.0.0.1

2)建立遠端登陸使用者並授權

> grant all privileges on discuz.* to

ted@'123.123.123.123' identifiedby '123456';

上面的語句表示將 discuz 資料庫的所有許可權授權給 ted 這個使用者,允許 ted 使用者在123.123.123.123 這個 ip 進行遠端登陸,並設定 ted 使用者的密碼為 123456 。

下面逐一分析所有的引數:

all privileges表示賦予所有的許可權給指定使用者,這裡也可以替換為賦予某一具體的許可權,例如:select,insert,update,delete,create,drop等,具體許可權間用「,」半形逗號分隔。

discuz.* 表示上面的許可權是針對於哪個表的,discuz 指的是資料庫,後面的 *表示對於所有的表,由此可以推理出:對於全部資料庫的全部表授權為「*.*」,對於某一資料庫的全部表授權為「資料庫名.*」,對於某一資料庫的某一表授權為「資料庫名.表名」。

ted 表示你要給哪個使用者授權,這個使用者可以是存在的使用者,也可以是不存在的使用者。

123456 為使用者的密碼。

執行了上面的語句後,再執行下面的語句,方可立即生效。

> flush privileges;

2.修改root密碼

1)關閉mysql

# service mysqld stop

2)遮蔽許可權

# mysqld_safe--skip-grant-table

螢幕出現: starting demo from.....

3)新開起乙個終端輸入

# mysql -u root mysql

mysql> updateuser set password=password('newpassword') where user='root';

mysql> flushprivileges;//記得要這句話,否則如果關閉先前的終端,又會出現原來的錯誤

mysql> \q

Mysql相關問題收集

1.查詢每個班級的前三名 drop table if exists sc create table sc id int 11 not null auto increment,name varchar 200 character set utf8 default null,class varchar ...

mysql命令收集

將常用的命令收集下,免得總是查手冊。登入mysql伺服器 mysql u p 檢視現有資料庫 show databases 使用某資料 use table name 建立表 create table table name column name column definition,檢視現有表 sho...

MySQL語句收集

1 查詢列名 第乙個引數為資料庫名,第二個引數為表名 select column name from information schema.columns where table schema test and table name tb grade 2 顯示表結構 desc information...