Installation of Linux version (too simple)
Installation:
?
1 |
yum install mysql - server |
Service-side startup
?
Client connections
?
1234567 |
连接: mysql -h host -u user -p 常见错误: ERROR 2002 (HY000): Can ‘t connect to local MySQL server through socket ‘ /tmp/mysql.sock‘ (2), it means that the MySQL server daemon (Unix) or service (Windows) is not running. 退出: QUIT 或者 Control+D |
Third, database operation
1. Display Database
?
Default database:
MySQL-User rights-related data
Test-for user testing data
Information_schema-mysql itself schema-related data
2. Create a database
?
12345 |
# utf-8 CREATE DATABASE 数据库名称 DEFAULT CHARSET utf8 COLLATE utf8_general_ci; # gbk CREATE DATABASE 数据库名称 DEFAULT CHARACTER SET gbk COLLATE gbk_chinese_ci; |
3. Using the Database
?
Displays all tables in the currently used database: show TABLES;
4. User Management
?
12345678910 |
创建用户
create user
‘用户名‘
@
‘IP地址‘ identified by
‘密码‘
;
删除用户
drop user
‘用户名‘
@
‘IP地址‘
;
修改用户
rename user
‘用户名‘
@
‘IP地址‘
; to
‘新用户名‘
@
‘IP地址‘
;;
修改密码
set password
for ‘用户名‘
@
‘IP地址‘ = Password(
‘新密码‘
)
PS:用户权限相关数据保存在mysql数据库的user表中,所以也可以直接对其进行操作(不建议)
|
5. Authorization Management
?
123 |
show grants for ' user ' @ ' IP address ' --View permissions grant permissions on the database. Table to ' user ' @ ' IP address ' Code class= "JavaScript plain" >--authorized revoke permissions on the database. Table from ' user ' @ ' IP address ' --Remove permissions |
All privileges except grant all permissions select only Check permissions Select,insert check and insert Permissions ... Usage No access permission ALTER use ALTER TABLE ALTER routine Using the ALTER procedure and drop procedure create, use the CREATE table create routine to make Using CREATE PROCEDURE create temporary tables use create temporary tables create user using Create User, drop user, rename user, and revoke all privileges CREATE view use the CREATE VIEW delete Use the drop table execute using the call and stored procedure using delete drop File uses SELECT INTO outfile and load data infile grant option using GRANT and REVOKE Index use the Insert lock tables with index insert Using the Lock table Process using show full Processlist select using Select Show Databases Using show databases show view to use the update with show view update Reload using flush shutdown using mysqladmin shutdown (turn off MySQL) super ???? Use change master, kill, logs, purge, master, and set global. also allows mysqladmin???????? Debug login Replication Client server location access replication slave used by replication slaves
for Permissions
For the target database and other internal: database name. * all database names in the database. The table specifies a table database name in the database . Stored procedures in the specified database for stored procedures * . All databases
for Database
User name @ip address users can only access the user name under the change IP @192.168.1.% The user is only allowed to access the IP segment (the wildcard% means any) user name @% The user may then access under any IP ( Default IP address is%)
for users and IP
Grant all privileges the DB1.TB1 to ' user name ' @ ' IP ' grant Select on db1.* to ' username ' @ ' IP ' grant Select,insert on * * to ' Username ' @ ' IP ' revoke select on DB1.TB1 from ' username ' @ ' IP '
Example
Special:
?
1 |
flush privileges,将数据读取到内存中,从而立即生效。 |
mysql-Part II (Installation of Linux version and operation of datasheets)