{"id":4774,"date":"2014-10-10T14:21:29","date_gmt":"2014-10-10T19:21:29","guid":{"rendered":"https:\/\/secure.rosehosting.com\/blog\/?p=4774"},"modified":"2022-06-03T03:46:38","modified_gmt":"2022-06-03T08:46:38","slug":"basic-mysql-database-administration-on-a-linux-vps","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/","title":{"rendered":"Basic MySQL database administration on a Linux VPS"},"content":{"rendered":"
MySQL is one of the most popular relational database management systems (RDBMS). It is open-source and it is used by many individuals and organizations. If you are using our Linux VPS hosting<\/a> services, you are most likely using MySQL as a database system. Therefore, it is important for you to know how to operate with your database system when you need to make some changes in your databases. Today, we will have a very simple task – to teach you how to work with your MySQL database system using these simple commands from your Linux VPS<\/a>.<\/p>\n <\/p>\n The first thing you need to do is to check your MySQL version using the command:<\/p>\n If by any chance you do not have MySQL database server installed on your VPS, you can install it using the commands:<\/p>\n if you have a CentOS VPS<\/a>, or:<\/p>\n if you have an Ubuntu VPS<\/a> or Debian VPS<\/a>.<\/p>\n Before going even further, you may want to create a backup of your existing databases so you can proceed with this tutorial safely. Please\u00a0 check our blog post on How to backup and restore your MySQL database<\/a><\/p>\n Now, let’s start with the actual tutorial.<\/p>\n To log in to your MySQL database server you can run the command:<\/p>\n For instance, if you like to log in as ‘root’, you can run the command:<\/p>\n You will be prompted for your database ‘root’ password. Please note, your database ‘root’ password may not be the same as your SSH ‘root’ password.<\/p>\n Once you successfully log in to your MySQL database server, you can list all the databases using the command:<\/p>\n If you like to create a database, you can use the command:<\/p>\n Replace the ‘db_name’ with the name of the database you like to create.<\/p>\n Additionally, if you like to delete some of the databases, you can simply enter the command:<\/p>\n Again, replace the ‘db_name’ with the name of the database you like to delete.<\/p>\n Next, if you like to use some of the databases, type:<\/p>\n Once you select the database you like to use, you can list all the tables using the command;<\/p>\n For instance, let’s create a ‘test’ database and use it:<\/p>\n You can now create a table ‘test_table’ using the command:<\/p>\n To show all data in a table you can use the command:<\/p>\n If you run the command:<\/p>\n You will get an ‘Empty set’ message. This is because the ‘test_table’ is new and does not hold any data.<\/p>\n In the next tutorial, we will show you how to insert and manipulate data into your tables.<\/p>\n Of course, you don\u2019t have to do any of this if you use one of our Linux VPS hosting services,<\/a> in which case you can simply ask our expert Linux admins to do this for you. They are available 24\u00d77 and will take care of your request immediately. For more options, kindly read Basic MySQL Database Administration on Linux VPS \u2013 Part 2<\/a>.<\/p>\n PS<\/span>. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":" MySQL is one of the most popular relational database management systems (RDBMS). It is open-source and it is used by … <\/p>\n## mysql -h localhost -V<\/pre>\n
## yum install mysql-server<\/pre>\n
## apt-get install mysql-server<\/pre>\n
## mysql -u username -p<\/pre>\n
## mysql -u root -p<\/pre>\n
mysql> SHOW DATABASES;<\/pre>\n
mysql> CREATE DATABASE db_name;<\/pre>\n
mysql> DROP DATABASE db_name;<\/pre>\n
mysql> USE db_name;<\/pre>\n
mysql> SHOW TABLES;<\/pre>\n
mysql> CREATE DATABASE test;\nmysql> USE test;<\/pre>\n
mysql> CREATE TABLE test_table (\nid INT NOT NULL PRIMARY KEY AUTO_INCREMENT,\nname VARCHAR(30) NOT NULL,\ncomment VARCHAR (100)\n);<\/pre>\n
mysql> SELECT * FROM db_name;<\/pre>\n
mysql> SELECT * FROM test_table;<\/pre>\n