Mysql Basic Command
Mysql Basic Command
https://oracle-base.com/articles/mysql/mysql-installation-on-linux
If you have fresh installation of MySQL server, then it doesn’t require any password to connect it as root
user. To set MySQL password for root user, use the following command.
If you would like to change or update MySQL root password, then you need to type the following
command. For example, say your old password is 123456 and you want to change it with new password
say xyz123.
To find out whether MySQL server is up and running, use the following command.
To find out current status of MySQL server, use the following command. The mysqladmin command
shows the status of uptime with running threads and queries.
To check all the running status of MySQL server variables and values, type the following command. The
output would be similar to below.
Or
The following command will display all the running process of MySQL database queries.
To create a new database in MySQL server, use the command as shown below.
To drop a Database in MySQL server, use the following command. You will be asked to confirm press ‘y‘.
# mysqladmin -u root -p drop databasename
The reload command tells the server to reload the grant tables. The refresh command flushes all tables
and reopens the log files.
You can also use the following commands to start/stop MySQL server.
# /etc/init.d/mysqld stop
# /etc/init.d/mysqld start
If you like to kill multiple process, then pass the process ID‘s with comma separated as shown below.
If you would like to execute multiple ‘mysqladmin commands together, then the command would be
like this.
To connect remote MySQL server, use the -h (host) with IP Address of remote machine.
Let’s say you would like to see the status of remote MySQL server, and then the command would be.
It tells the server to write debug information about locks in use, used memory and query usage to the
MySQL log file including information about event scheduler.
To find out more options and usage of myslqadmin command use the help command as shown below. It
will display a list of available options.
# mysqladmin --help