In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article analyzes "what are the basic commands for operating mysql on the Linux system?" The content is detailed and easy to understand, and friends who are interested in "what are the basic commands for operating mysql in the Linux system" can follow the editor's train of thought to read it in depth. I hope it will be helpful to everyone after reading. Let's follow the editor to learn more about "what are the basic commands for operating mysql in the Linux system".
When you search for this question on Baidu, it shows that you have some preliminary understanding of MySQL. Here are the basic commands for operating MySQL in the Linux system.
Install the mysql command: $sudo apt-get install-y mysql-server
Check the mysql version command (note that-V is uppercase, otherwise the following error will occur): $mysql-V
Start the mysql command (other functions such as shutdown, restart, etc., just change start to the corresponding stop,restart and other letters): $sudo service mysql start
This command requires root permission to be used, and there is no prompt after a successful startup, just for linux, no news is good news, so don't worry, it has been started successfully.
(root permission: from an "account" point of view, it refers to the identity of a "system administrator", that is, a superuser with the highest privileges. From a directory point of view, it refers to the "root directory", that is, "/"
Obviously this paragraph refers to the first case: the system administrator. )
After startup, enter the mysql command as follows: $mysql-u user name-packs * password * *
Login for the first time, the user name is generally root, the password will prompt you to enter after the installation. After successfully entering mysql, the prompt on the command line becomes "mysql >". Because the mysql command is a little different from the linux command, because mysql commands always end with ";". This requires a little attention. (the above password can be entered directly after-p or on the second line, the difference is that the password on the second line appears in an invisible form.)
After entering mysql, first check the database: > show databases; (pay attention to the semicolon ";" Don't leave behind) the system will bring several pieces of data, such as performance_schema, information_schema,mysql. It is best not to delete these self-contained databases in case it is abnormal.
After looking at the database, there are two possibilities: either build a new database yourself or delete a database, so I record the two together and know that they are at the same level when I use them.
Create a new database command: > create database database name
Delete a database command: > drop database database name; (the database name "fuck" is taken as an example in the following picture)
In order to cooperate with the next step, we chose to build a new database, named "newone", so the question is, with so many databases, you want to add some data to "newone", so how does mysql know that you want to use this database instead of other databases? To do this, use the command: > use database name
The following figure takes the database newone as an example; after successfully switching the database, the system will prompt that the database has been switched. For example, if you are in a hotel with many rooms, the innkeeper gives you the key to the room you want, so now you are free to enter that room.
Whether it is a new house or a hotel room, after we enter, we should first check the situation. Take the hotel as an example: such as the location of the bed, whether the light is sufficient, whether the toilet is big enough, whether the quilt on the bed has been slapped and whether the etc has been changed.
The same is true for the database, first check the "tables" in the database (there is no doubt that many tables can be placed in the database, just like a wide variety of furniture can be placed in the room. Check to see if there are any tables or the tables you need).
Look at the table command: > show tables; (because it is a new table, just like a newly bought house, it is empty. )
Similar to adding furniture to a new house, we want to add tables to the database:
Create a new table: > create table table name (field parameter) or > create table if not exists table name (field parameter)
Delete an old table: > drop table table name; or > drop table if exists table name
The following figure takes the table name person as an example, and the field parameters are briefly described in the second section.
What are the versions of Linux? the versions of Linux are Deepin, UbuntuKylin, Manjaro, LinuxMint, Ubuntu and so on. Among them, Deepin is one of the best-developed Linux distributions in China; UbuntuKylin is a derivative release based on Ubuntu; Manjaro is a Linux release based on Arch; LinuxMint's default Cinnamon desktop is similar to Windows XP's easy-to-use; Ubuntu is the Linux operating system based on desktop applications.
About the Linux system operation mysql basic command which shares here, hoped that the above content can let everybody have the promotion. If you want to learn more knowledge, please pay more attention to the editor's updates. Thank you for following the website!
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.