Mysql報錯130 MySQL常用命令

2021-10-18 22:25:40 字數 3181 閱讀 6363

習慣了oracle後,第一次用mysql會不適應。在未選擇mysql的客戶端之前,都是使用命令列。

1、登入

mysql -p 31306 -u uacuser1 -puacuser1

mysql -p3020 -h 130.51.23.246 -uroot -proot

mysql -p3020 -h 130.51.23.246 -uroot -p

安裝了mysql後可以使用mysql命令。

-p:埠。可有空格,也可沒有。

-u:使用者名稱。可有空格,也可沒有。root是最高許可權使用者。其他使用者可以通過root建立。

-h:ip。mysql伺服器所在的主機,如果沒有預設 - 就是本機,本機的話必須是mysql使用者。

-p:密碼。必須沒有空格,緊跟-p。也可以-p後留空,提示你輸入密碼時再輸入。

查詢當前使用者:

select user();

2、建立使用者

create user 『uacuser1『@『localhost『 identified by 『123456『;

create user 『uacuser1『@『aipaas03『 identified by 『123456『;

create user 『uacuser1『@『%『 identified by 『123456『;

查詢使用者

select user,host from mysql.user order by user;

刪除使用者:

delete from mysql.user where user=『uacdb『 and host=『localhost『;

delete from mysql.user where user=『uacdb『 and host=『aipaas03『;

delete from mysql.user where user=『uacdb『 and host=『%『;

flush privileges;

3、建立資料庫

create database uacdb;

grant all privileges on uacdb.* to uacuser1@"%" identified by "123456";

grant all privileges on uacdb.* to uacuser1@"localhost" identified by "123456";

grant all privileges on uacdb.* to uacuser1@"aipaas03" identified by "123456";

flush privileges;

mysql新設定使用者或更改密碼後需用flush privileges重新整理mysql的系統許可權相關表,否則會出現拒絕訪問,還有一種方法,就是重新啟動mysql伺服器,來使新設定生效。

mysql建庫必須用root建,然後賦權使用者。

查詢資料庫:

show databases;

進入某個資料庫(database_name是具體的庫名):

use database_name;

刪除資料庫:

drop database if exists database_name;

4、刪表/建表

必須進入某個庫後才能進行。

drop table if exists `auth_center`;

create table `auth_center` (

`auth_id` bigint(20) not null auto_increment,

`auth_password` varchar(48) collate utf8_bin not null,

`auth_source` varchar(16) collate utf8_bin not null default 『『,

`auth_param` varchar(2048) collate utf8_bin default null,

`auth_state` varchar(2) collate utf8_bin not null,

`auth_register_time` timestamp not null,

`auth_active_time` timestamp null default null,

primary key (`auth_id`)

) engine=innodb auto_increment=617 default charset=utf8 collate=utf8_bin;

查詢表:

show tables;

檢視表結構:

desc table_name;

dml:

使用標準的dml即可。select、insert、update、delete。

5、檢視事務是否自動提交

show variables like 『%autocommit%『;

6、檢視mysql版本四種方法

mysql –v

mysql --help | grep distrib

status

select version();

7、退出

quit

exit

8、報錯解決

error 1044 (42000): access denied for user [email protected] to database 『protaldb』

解決:use protaldb時遇到,protaldb寫錯了;create database時遇到,必須用root使用者。

error 1045 (28000): access denied for user [email protected] (using password: yes)

解決:使用者名稱或者密碼錯了。

error 1046 (3d000): no database selected

解決:要先use 庫名。

error 2002 (hy000): can』t connect to local mysql server through socket 『/var/lib/mysql/mysql.sock』 (2)

解決:登入時遇到。需要-h mysql所在主機。或者用mysql的使用者登入主機。

error 2006 (hy000): mysql server has gone away

解決:grant all privileges 時遇到,可忽略。

2015.6.20

mysql重啟報錯 mysql 重啟報錯問題處理

停止服務報錯 命令 etc init.d mysqld stop error mysql server pid file could not be found 1.在進行了刪除mysqlbinlog二進位制日誌 操作為 purge binary logs to mysql bin.000002 2....

登陸mysql 報錯 mysql 登入報錯

執行命令 mysql u root p 錯誤 error while loading shared libraries libncurses.so.5 cannot open shared object file 分析 缺少 libncurses.so.5 解決方案 yum install libn...

MYSQL 啟動報錯

我先說一下我安裝mysql的操作吧 1 開始的時候,安裝mysql,是那種解壓縮就能用的軟體包。我把它解壓後,拷貝到 usr local 目錄下,並把名字命名為mysql。2 建立使用者mysql。root localhost useradd mysql 3 修改許可權。root localhost...