In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
First: start and stop the mysql service
Net stop mysqlnet start mysql
Second: log in
Mysql-u username [- h hostname or IP address]-p password
Description: the user name is the user you logged in, the host name or IP address is optional, not required if it is a local connection, the remote connection needs to be filled in, and the password is the password of the corresponding user.
Third: add new users
Format: grant permission on database. * to user name @ login host identified by "password"
For example, add a user's user1 password to password1, so that it can log in on the local computer, and have the authority to query, insert, modify and delete all databases. First use the root user to connect to mysql, and then type the following command:
Grant select,insert,update,delete on *. * to user1@localhost Identified by "password1"
If you want the user to be able to log in to mysql on any machine, change localhost to "%".
If you don't want user1 to have a password, you can issue another command to remove the password.
Grant select,insert,update,delete on mydb.* to user1@localhost identified by ""
Fourth: operate the database
Log in to mysql and run the following commands at the mysql prompt, each ending with a semicolon.
1. Display the list of databases.
Show databases
There are two databases by default: mysql and test. Mysql stores the system and user rights information of mysql. When we change passwords and add new users, we actually operate on this library.
2. Display the data table in the library:
Use mysql;show tables
3. Display the structure of the data table:
Describe table name
4. Build and delete databases:
Create database library name; drop database library name
5. Create a table:
Use library name; create table table name (field list); drop table table name
6. Clear the records in the table:
Delete from table name
7. Display the records in the table:
Select * from table name
8. Set the encoding
Set names utf8
Change the password of a root user
Mysql > update mysql.user set password=PASSWORD ('new password') where User='root'; mysql > flush privileges
Fifth: export and import data
1. Export data:
Mysqldump-opt test > mysql.test
Export the database test database to a mysql.test file, which is a text file
For example: mysqldump-u root-p123456-- databases dbname > mysql.dbname
Is to export the database dbname to the file mysql.dbname.
two。 Import data:
Source D:\ ceshi.sql
This is the address where the sql file is stored.
Operation manual:
The field data of text data is separated by tab.
Use test;load data local infile File name into table table name
1: use the show statement to find out what databases currently exist on the server:
Mysql > SHOW DATABASES
2: create a database MYSQLDATA
Mysql > CREATE DATABASE MYSQLDATA
3: select the database you created
Mysql > USE MYSQLDATA; (if Database changed appears by pressing enter key, the operation is successful!)
4: see what tables exist in the current database
Mysql > SHOW TABLES
5: create a database table
Mysql > CREATE TABLE MYTABLE (name VARCHAR (20), sex CHAR (1))
6: display the structure of the table:
Mysql > DESCRIBE MYTABLE
7: add records to the table
Mysql > insert into MYTABLE values ("hyq", "M")
8: load data into database tables in text (for example, D:/mysql.txt)
Mysql > LOAD DATA LOCAL INFILE "D:/mysql.txt" INTO TABLE MYTABLE
9: import .sql file command (for example, D:/mysql.sql)
Mysql > use database;mysql > source d:/mysql.sql
10: delete the table
Mysql > drop TABLE MYTABLE
11: clear the table
Mysql > delete from MYTABLE
12: update data in the table
Mysql > update MYTABLE set sex= "f" where name='hyq'
13: rename the table name
For example, in the table MyClass the name is changed to YouClass:
Mysql > rename table MyClass to YouClass
14: modify field names and properties
Mysql > alter table test change t_name t_name_new varchar (20)
15: table insert / add new fields
Alter table `fy_ images` add newColumn varchar (8) NOT NULL COMMENT 'newly added field'
Summary
The above is the whole content of this article. I hope the content of this article has a certain reference and learning value for everyone's study or work. Thank you for your support. If you want to know more about it, please see the relevant links below.
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.