In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "MySql basic command finishing", in daily operation, I believe many people in MySql basic command finishing problems have doubts, Xiaobian consulted all kinds of information, sorted out simple and easy to use operation methods, hope to answer "MySql basic command finishing" doubts helpful! Next, please follow the small series to learn together!
Start and Stop of MySQL Services
net stop mysql
net start mysql
The second move, landing mysql
The syntax is as follows: mysql -u username-p password
Type the command mysql -uroot -p, enter and prompt you to enter the password, enter 12345, and then enter to enter mysql, mysql prompt is:
mysql>
Note that if you are connecting to another machine, you need to add a parameter-h Machine IP
Third, add new users
Format: grant permissions on database.* to username @ login host identified by "password"
For example, add a user user1 password to password1, so that it can log in on the local computer and have query, insert, modify and delete permissions for all databases. First connect to mysql as root and type the following command:
grant select,insert,update,delete on *.* to Identified by "password1";
Change localhost to "%" if you want this user to be able to log in to mysql on any machine.
If you don't want user1 to have a password, you can type another command to remove the password.
grant select,insert,update,delete on mydb.* to identified by "";
Fourth move: operation
Log in to, and then run the following commands at the mysql prompt, each ending with a semicolon.
1. Display the database list.
show databases;
By default, there are two databases: mysql and test. mysql library stores mysql system and user rights information, we change passwords and new users, in fact, is to operate this library.
2. Display the data tables in the library:
use mysql;
show tables;
3. Display the structure of the data table:
describe table name;
4. Library Creation and Deletion:
create database name;
drop database name;
5. Table:
use library name;
create table name (list of fields);
drop table name;
6. Clear the records in the table:
delete from table name;
7. Records in the display table:
select * from table name;
Step 5: Export and Import Data
1. Export data:
mysqldump --opt test > mysql.test
That is, export the database test database to the mysql.test file, which is a text file
For example: mysqldump -u root -p123456 --databases dbname > mysql.dbname
Export dbname to mysql.dbname.
2. Import data:
mysqlimport -u root -p123456
< mysql.dbname。 不用解释了吧。 3. 将文本数据导入数据库: 文本数据的字段数据之间用tab键隔开。 use test; load data local infile "文件名" into table 表名; 1:使用SHOW语句找出在服务器上当前存在什么数据库: mysql>SHOW DATABASES;
2:2, create a database MYSQLDATA
mysql> CREATE DATABASE MYSQLDATA;
3: Select the database you created
mysql> USE MYSQLDATA; (Press Enter to show Database changed, indicating successful operation!)
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 table structure:
mysql> DESCRIBE MYTABLE;
7: Add records to the table
mysql> insert into MYTABLE values ("hyq","M");
8: Load data into database tables as text (e.g. 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 a table
mysql>drop TABLE MYTABLE;
11: Empty the table
mysql>delete from MYTABLE;
12: Update data in tables
mysql>update MYTABLE set sex="f" where name='hyq';
posted on 2006-01-10 16:21 happytian Read (6) Comment (0) Edit Favorite to 365Key
13: Backup database
mysqldump -u root Library name> xxx.data
Example 2: Connecting to MYSQL on a remote host
Suppose the IP of the remote host is 110.110.110.110, the username is root, and the password is abcd123. Type the following command:
mysql -h210.110.110.110 -uroot -pabcd123
(Note:u and root can be used without spaces, and the same is true for others)
3. Exit MYSQL command: exit (carriage return)
At this point, on the "MySql basic command finishing" learning is over, I hope to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!
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.