In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "the command to start MySQL under the Linux system". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. To sum up:
1. The command to start MySQL under the system:
/ ect/init.d/mysql start (previous is the installation path of mysql)
Command to restart mysql under 2.linux:
/ ect/init.d/mysql restart (previous is the installation path of mysql)
The command to turn off mysql under 3.linux:
/ ect/init.d/mysql shutdown (previous is the installation path of mysql)
4. Connect the mysql on this computer:
Enter the directory mysql\ bin, type the command mysql-uroot-p, and press enter to prompt for the password.
Exit mysql command: exit (enter)
Mysql-uroot-- password= "" (note under root user)
5. Change the mysql password:
Mysqladmin-u username-p old password password new password
Or enter the mysql command line SET PASSWORD FOR root=PASSWORD ("root")
6. Add new users. (note: commands in the mysql environment are followed by a semicolon as a command Terminator)
Grant select on. * to username @ login host identified by "password"
Such as adding a user's test password to 123, so that he can log in on any host and have the authority to query, insert, modify and delete all databases. First connect with the root user, and then type the following command:
Grant select,insert,update,delete on *. * to "Identified by" 123"
II. Operations related to MySQL database
You must first log in to mysql, all at the mysql prompt, and each command ends with a semicolon
1. Display the list of databases.
Show databases
2. Display the data table in the library:
Use mysql; / / Open the library
Show tables
3. Display the structure of the data table:
Describe table name
4. Build the database:
Create database library name
5. Create a table:
Use library name
Create table table name (list of field settings)
6. Delete the library and the table:
Drop database library name
Drop table table name
7. Clear the records in the table:
Delete from table name
8. Display the records in the table:
Select * from table name
9. Modification of the code
To change the encoding format of the entire mysql:
When you start mysql, the mysqld_safe command line joins
-- default-character-set=gbk
To change the encoding format of a library: enter the command at the mysql prompt
Alter database db_name default character set gbk
III. Import and export of data
1. Transfer the text data to the database
The format that the text data should conform to: the field data is separated by the tab key, and the null value is used instead. Example:
1 name duty 2006-11-23
Data input command load data local infile "file name" into table table name
2. Export databases and tables
Mysqldump-- opt news > news.sql (back up all the tables in the database news to a news.sql file, where news.sql is a text file with any file name. )
Mysqldump-- opt news author article > author.article.sql (back up the author table and the article table in the database news to the author.article.sql file, where author.article.sql is a text file with any file name. )
Mysqldump-- databases db1 db2 > news.sql (back up the databases dbl and db2 to a news.sql file, where news.sql is a text file with any file name. )
Mysqldump-h host-u user-p pass-- databases dbname > file.dump
Is to import the database dbname with the name user and password pass on host into the file file.dump
Mysqldump-- all-databases > all-databases.sql (back up all databases to an all-databases.sql file, where all-databases.sql is a text file with any file name. )
3. Import data
Mysql source news.sql; (executed under the mysql command to import tables)
This is the end of the content of "the command to start MySQL under Linux system". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.