In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Log in to MySQL, and if you connect to a remote database, you need to specify hostname with-h.
# mysql-h hostname-u root-p
# mysql-uroot-p-S / data/3306/mysql.sock # Local login
Update the permissions / privileges of the database.
Mysql > flush privileges
View the field format of the data table.
Mysql > desc [table name]
Delete a database.
Mysql > drop database [database name]
Delete a data table.
Mysql > drop table [table name]
Mysql > delete from table name; clear table record
Delete the row of [user] = 'blog' in the table.
Mysql > DELETE from [table name] where [user] = 'blog'
Delete the column.
Mysql > alter table [table name] drop column [column name]
Add a column to db.
Mysql > alter table [table name] add column [new column name] varchar (20)
Change the column name.
Mysql > alter table [table name] change [old column name] [new column name] varchar (50)
Add a unique column.
Mysql > alter table [table name] add unique ([column name])
Set the column value to be larger.
Mysql > alter table [table name] modify [column name] VARCHAR (3)
Delete the unique column.
Mysql > alter table [table name] drop index [colmn name]
Change the field name to change, change the type to modify, and modify the field name.
Mysql > alter table students change couese courses char (10) after name
Mysql > insert into students (name,sex) value ('gao','m'); insert data into the table
Mysql > insert into students values ('aa33','mysql','20','m'); if no field is specified, it is all fields
Mysql > update students set courses='long'; update modify data. Modify all data without using where
Mysql > update students set courses='aaa' where name='lei'; using where
Mysql > delete from students where courses='aaa'; delete a row
Mysql > create user 'www'@'%' identified by' www123'; create user www password as www123
Mysql > show grants for 'www'@'%'; to view the user's permissions
Mysql > grant all privileges on mydb.* to 'www'@'%'; grants weight to www for all tables of mydb
Create a new user. Log in as root. Switch to the mysql database, create users, and refresh permissions.
# mysql-u root-p
Mysql > use mysql
Mysql > INSERT INTO user (Host,User,Password) VALUES ('%', 'www',PASSWORD (' 123456'))
Mysql > flush privileges
Mysql > alter table students add couese char (100); add field
Export a database.
# mysqldump-u username-ppassword-- databases databasename > / tmp/databasename.sql
Export a table from a database.
# mysqldump-c-u username-ppassword databasename tablename > / tmp/databasename.tablename.sql
Restore the database (datasheet) from the sql file.
# mysql-u username-ppassword databasename < / tmp/databasename.sql
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.