In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to start mysql under linux". In daily operation, I believe many people have doubts about how to start mysql under linux. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to start mysql under linux". Next, please follow the editor to study!
The command to start mysql under 1.linux:
Mysqladmin start
Www.2cto.com
/ ect/init.d/mysql start (previous is the installation path of mysql)
Command to restart mysql under 2.linux:
Mysqladmin restart
/ ect/init.d/mysql restart (previous is the installation path of mysql)
The command to turn off mysql under 3.linux:
Mysqladmin-u root-p password shutdown
/ 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)
5. Change the mysql password:
Www.2cto.com
Mysqladmin-u username-p old password password new password
Or enter the mysql command line SET PASSWORD FOR 'username' @ 'host' = PASSWORD ('password')
GRANT USAGE ON *. * TO 'username' @ 'host' IDENTIFIED BY 'biscuit'
Change your password SET PASSWORD = PASSWORD ('biscuit')
6. Add new users. (note: commands in the mysql environment are followed by a semicolon as a command Terminator)
Grant all privileges on *. * to username @'% 'identified by' password 'with grant option
Flush privileges; (refresh permission settings)
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"
7. Skip authorized access to mysql
Mysqld_safe-user=mysql-skip-grant-tables-skip-networking &
II. Operations related to my
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.
Www.2cto.com
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
Www.2cto.com
-- 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 and article tables in the database news to an 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 the 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
< all-databases.sql(导入数据库) mysql -u root -p fukai –force < dmc010003_db.myisam.sql(强行导入) mysql>Source news.sql; (executed under the mysql command to import tables)
An introduction to the common options for MySQLimport:
Www.2cto.com
-d or-- delete delete all information in the data table before the new data is imported into the data table
-- for-- force will force data insertion to continue regardless of whether an error is encountered or not
-I or-- ignore MySQLimport skips or ignores lines with the same unique keyword, and the data in the import file is ignored.
-l or-lock-tables data locks the table before it is inserted, which prevents users' queries and updates from being affected when you update the database.
The-r or-replace option is the opposite of the-I option; this option replaces the record with the same unique keyword in the representative.
-- fields-enclosed- by= char specifies what is enclosed when recording data in a text file, and in many cases the data is enclosed in double quotes. By default, the data is not enclosed in characters.
-- fields-terminated- by=char specifies the delimiter between the values of each data. In a period-delimited file, the delimiter is a period. You can use this option to specify a separator between data.
The default delimiter is the jumper (Tab)
-- lines-terminated- by=str this option specifies the delimited string or character of the data between lines in the text file. By default, MySQLimport uses newline as the line delimiter.
You can choose to replace a single character with a string:
A new line or a carriage return.
Other common options for the MySQLimport command are-v display version (version) and-p prompt for password (password)
Example: import a file with a comma delimiter
The record format of the lines in the file is as follows:
"1", "ORD89876", "1 Dozen Roses", "19991226"
Our task is to import the data from this file into the table Orders in the database Meet_A_Geek. We use this command:
Bin/MySQLimport-prl-fields-enclosed-by= "- fields-terminated-by=, Meet_A_Geek Orders.txt
Www.2cto.com
1. Connect MySQL
Format: mysql-h host address-u user name-p user password
1. Example 1: connect to the MYSQL on this machine.
First of all, open the DOS window, then enter the directory mysqlbin, and then type the command mysql-uroot-p. Enter prompts you to enter the password. If you have just installed MYSQL, the superuser root does not have a password, so you can enter the MYSQL directly by entering the enter. The prompt for MYSQL is: mysql >.
Example 2: connect to the MYSQL on the remote host. Suppose the IP of the remote host is 110.110.110.110, the user name is root, and the password is abcd123. Type the following command:
Mysql-h210.110.110.110-uroot-pabcd123
(note: U and root do not have to add spaces, and so do others)
3. Exit the MYSQL command: exit (enter).
Mysql common maintenance commands
1. Show global status; lists the various status values of the MySQL server running
2. Show variables; query MySQL server configuration information statement
3. View slow query
Show variables like'% slow%'
Show global status like'% slow%'
4. Maximum number of connections
Maximum number of connections to show variables like 'max_connections';MySQL server
Www.2cto.com
Maximum number of connections responded by the show global status like 'Max_used_connections'; server
5. View the table structure
Desc Tablename
Describe Tablename
Show columns from Tablename
Show create table Tablename
At this point, the study on "how to start mysql under linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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: 274
*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.