How to use mysql after installation

How to use mysql after installation

Occasionally in our daily life, we will encounter some problems that we don’t know how to solve, such as using the installed mysql. so how should we solve this kind of situation that we don’t know how to use the installed mysql? Then the next step is for me to introduce the steps to use the installed mysql.

The operation of the Dell computer as an example, the specific steps are as follows:

Step 1:

First, open MySQLWorkbench, double-click to open. After opening the interface is shown below, and then select the database instance, double-click to log in. The database instance in the figure is LocalinstanceMYSQL57

Step 2:

Then, enter your username and password to log in. As shown below:

Step 3:

After successful login, the interface is shown below. Among them, Area 1 shows the list of databases that have been created in the database server. Area 2 is the list of operations on the database. Area 3 is the editor and execution environment of sql, and area 4 is the list of execution results

Step 4:

Enter the test statement in the editor of sql as shown in the figure, in which world database is the test database that comes with mysql, and then choose to execute it (or use the shortcut key ctrl+enter). After successful execution, the query results will be displayed in the list below.

Step 5:

When you’re done, exit directly, and remember to shut down the MySQL service if you don’t need to follow up with the database.

How to start mysql after installing it with fedora16yum and adding it as a system service_MySQL


How to start mysql after installing it with fedora16yum and adding it as a system service

1yum install mysql


If you encounter ERROR2002(HY000):Can’tconnecttolocalMySQLserverthroughsocket’/var

you can use the following command:

Start mysql service


Set mysqld to boot self-start


2, systemctl usage

This command is a system process management commands; comparison table to apache/httpd as an example

Tasks old commands new commands

To make a service start automatically chkconfig–level3httpdonsystemctlenablehttpd. service

Make a service not start automatically chkconfig–level3httpdoffsystemctldisablehttpd.service

Check the status of a service servicehttpdstatussystemctlstatushttpd. service (service details) systemctlis-activehttpd.service (only shows if it is Active)

Show all started services chkconfig–listsystemctllist-units–type=service

Start a service servicehttpdstartsystemctlstarthttpd.service

Stop a service service servicehttpdstopsystemctlstophttpd.service

Restart a service servicehttpdrestartsystemctlrestarthttpd.service

3. After installation, you can check the installation location of the corresponding commands of mysql in this way

Find the installation location of the mysql server files

#rpm-qlmysql- server

Find where the mysql client files are installed


4. The system does not have a mysql management database installed by default, so run the install command


Or add the parameter

# mysql_install_db –user=root –basedir=/usr –datadir=/var/lib/mysql

After installing the mysql management database, you can start mysql, and you can check the values of the corresponding basedir and datadir like this.

Start mysql

#mysqld_safe –user=root&

Look up the process number of mysqld


End mysqld, the process number is obtained by the above command, note that it is the value of /usr/ bin/mysqld, not /bin/sh/usr/bin/mysqld_safe.


5, download a mysql Linux binary zip installer (version number is almost the same, for example, are 5.5.xx) in the support-files/mysql.server file, modify two lines.



Search for the ‘start’ paragraph in $bindir/mysqld_safe–datadir=”$datadir” and change it to $bindir/mysqld_safe– user=root –datadir=”$datadir”.




To this point, mysql has been successfully registered as a service, and you can use the # servicemysqldstart|stop|restrat command to run mysql.

Starting mysql


Adding password 123 to mysql’s root user


Using the mysql command line client

# mysql-uroot-p123

6. Starting mysqld.service appears to be unable to start

When starting the service with servicemysqldstart, the following error occurs:

Redirectingto/bin/ systemctlstartmysqld.service


When starting the service with systemctlstartmysql.service, the following error occurs:

The following error occurs when typing mysql directly:

ERROR2002(HY000):Can’tconnecttolocalMySQLserverthroughsocket’/var/lib/mysql/mysql.sock'(2 )

Solution: the owner of mysql is root, and mysql is executed with the mysql user identity of course not write in, is the problem of system permissions, chown-Rmysql:mysql/var/lib/mysql/ on it

Teaching You How to Safely Apply MySQL_MySQL

MySQL has become one of the most used databases on the Web today, especially in Web applications, where it occupies an absolute dominant position in small and medium-sized applications. This is all due to its small size and ease of use, security and effectiveness, open licensing and multi-platform, and more importantly, its perfect combination with one of the three major web languages – PHP. Unfortunately, however, a default secure MySQL can be overflowed due to empty root passwords and program vulnerabilities, making the server where MySQL is installed a frequent target of attack. Worse, databases are often corrupted after an attack, with catastrophic consequences. The following will enter in order to protect the data and the defense of the war. Environmental requirements 1. System environment has a RedHatLinux 9.0 custom installation of the server, the system installed GCC and some software packages, such as Apache, PHP and so on. The first thing to do after installing the system is to upgrade the system’s software packages. As a web server, the system accepts requests for PHP scripts, and PHP uses the MySQL database that will be installed below as a contact for dynamic publishing. The partitioning requirements are similar to those of a normal system, except that /chroot and /tmp, which are created later, are required to be on the same partition. 2. Security Requirements (1) MySQL is running in a separate (Chroot) environment;

(2) The mysqld process is running under a separate user/user group that has no root directory, no shell, and can’t be used for other programs;

(3) change the root account for MySQL and use a complex password;

(4) only allow local connections to MySQL, and network connections are disabled when starting MySQL;

(5) make sure that logins to the nobody account that connects to MySQL are

(6) Delete the test database. Installing MySQL1. Before you prepare to install MySQL, you need to create a user and group for starting MySQL according to the above security requirements. #groupaddmysql

#useraddmysql-c “startmysqld’saccount”-d/dev/null-gmysql-s/sbin/nologin2.Compile and InstallationDownload the MySQL source package:#wgethttp://mysql.he .net/Downloads/MySQL-4.0/mysql-4.0.16.tar.gz

Unzip:#tar-zxvfmysql-4.0.16.tar.gz Generally, MySQL is installed under /usr/local/mysql, and can be adapted to meet special requirements. However, this does not make much sense, because the back will Chrooting, then just use the client tools here, such as mysql, mysqladmin, mysqlmp and so on. Let’s start compiling and installing. #. /configure–prefix=/usr/local/mysql



–with- mysqld-ldflags=-all-static



#scripts/mysql_ install_db




How to log in to mysql?

When the MySQL service is turned on, you can log in to the MySQL database through the client. You can use DOS commands to log in to the database under the Windows operating system. This section describes how to log in to the MySQL database using the command method.

The specific steps for logging in to a MySQL database are as follows:

Step 1): Click Start → Windows System → Command Prompt. “, as shown in the figure.

Step 2): Open the Command Prompt interface, enter the command cdC:\ProgramFiles\MySQL\MySQLServer5.7\bin\, press the Enter key, as shown in the figure.

Step 3): You can connect to the MySQL database at the command prompt interface by logging in with the command mysql-h127.0.0.1-uroot-p.

Press the Enter key, the system will prompt for the password (Enterpassword), here enter the password set in the configuration wizard, after verifying the correct, you can log in to the MySQL database, as shown in the figure.

Tips: mysql is the login command, -h after the parameter is the host address of the server, here the client and the server on the same machine, so enter localhost or IP address; -u after the login database with the name of the user, in this case root; -p after the user login password.

Run the command in a DOS window and you will be prompted for a password. Once the password is entered correctly, you can log in to the MySQL database.

You can add the password directly to the mysql command, mysql-hlocalhost-uroot-proot, where root followed by -p is the password. Note that there is no space between -p and the password. If there is a space, the system will not treat the string that follows as a password.

Step 4): After logging in successfully and entering the initial MySQL interface, the welcome message “WelcometotheMySQLmonitor” will appear, and then there are some explanatory statements below, as shown in the figure.

These descriptive statements are as follows:

Commandsendwith;or\g: Commands on the mysql command line end with a semicolon (;) or “\g”, and the execution of commands begins when the terminator is encountered.

YourMySQLconnectionidis3: id indicates the number of connections to the MySQL database.

Serverversion:5.7.29-logMySQLCommunityServer (GPL): Serverversion followed by the version of the database, which is 5.7.29. community indicates that this version is the community version.

Type ‘help;’ or ‘\h’ forhelp: indicates that you can see help information by typing “help;” or “\h”.

Type’\c’toclearthecurrentinputstatement: indicates that encountering “\c” clears the previous command.

Hint: When the message shown above appears in the window and the command prompt changes to “mysql>”, it indicates that you have successfully logged in to the MySQL server and can start operating on the database.

Logging in via Command Line Client Software

When MySQL software is installed, a simple command-line application (MySQLCommandLineClient) is usually installed, which does not have a popular user interface.

Select Start > Programs > MySQL > MySQL 5.7. CommandLineClient”, open MySQLCommandLineClient to enter the interface prompting for a password, as shown in the figure.

Please click to enter a description of the image

After entering the correct password, you will be logged in to the MySQL software. If you log in to MySQL this way, you will need to make sure that the MySQL service is in the startup state.

If the program window flashes back after entering the password, then you can refer to the section MySqlCommandLineClient Flashback Solution.