{"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":"
<\/div>

\"mysql\"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

## mysql -h localhost -V<\/pre>\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

## yum install mysql-server<\/pre>\n

if you have a CentOS VPS<\/a>, or:<\/p>\n

## apt-get install mysql-server<\/pre>\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

## mysql -u username -p<\/pre>\n

For instance, if you like to log in as ‘root’, you can run the command:<\/p>\n

## mysql -u root -p<\/pre>\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

mysql> SHOW DATABASES;<\/pre>\n

If you like to create a database, you can use the command:<\/p>\n

mysql> CREATE DATABASE db_name;<\/pre>\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

mysql> DROP DATABASE db_name;<\/pre>\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

mysql> USE db_name;<\/pre>\n

Once you select the database you like to use, you can list all the tables using the command;<\/p>\n

mysql> SHOW TABLES;<\/pre>\n

For instance, let’s create a ‘test’ database and use it:<\/p>\n

mysql> CREATE DATABASE test;\nmysql> USE test;<\/pre>\n

You can now create a table ‘test_table’ using the command:<\/p>\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

To show all data in a table you can use the command:<\/p>\n

mysql> SELECT * FROM db_name;<\/pre>\n

If you run the command:<\/p>\n

mysql> SELECT * FROM test_table;<\/pre>\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

Read More<\/a><\/p>\n","protected":false},"author":4,"featured_media":4670,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1702,21,13],"tags":[39],"yoast_head":"\nBasic MySQL database administration on a Linux VPS - RoseHosting<\/title>\n<meta name=\"description\" content=\"Basic MySQL database administration on a Linux VPS - RoseHosting\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Basic MySQL database administration on a Linux VPS - RoseHosting\" \/>\n<meta property=\"og:description\" content=\"Basic MySQL database administration on a Linux VPS - RoseHosting\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/\" \/>\n<meta property=\"og:site_name\" content=\"RoseHosting\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/RoseHosting\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/rosehosting.helpdesk\" \/>\n<meta property=\"article:published_time\" content=\"2014-10-10T19:21:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-06-03T08:46:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2014\/09\/mysql.png\" \/>\n\t<meta property=\"og:image:width\" content=\"390\" \/>\n\t<meta property=\"og:image:height\" content=\"201\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Jeff Wilson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@rosehosting\" \/>\n<meta name=\"twitter:site\" content=\"@rosehosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeff Wilson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/\"},\"author\":{\"name\":\"Jeff Wilson\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713\"},\"headline\":\"Basic MySQL database administration on a Linux VPS\",\"datePublished\":\"2014-10-10T19:21:29+00:00\",\"dateModified\":\"2022-06-03T08:46:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/\"},\"wordCount\":526,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2014\/09\/mysql.png\",\"keywords\":[\"mysql\"],\"articleSection\":[\"Databases\",\"Tips and Tricks\",\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/\",\"url\":\"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/\",\"name\":\"Basic MySQL database administration on a Linux VPS - RoseHosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2014\/09\/mysql.png\",\"datePublished\":\"2014-10-10T19:21:29+00:00\",\"dateModified\":\"2022-06-03T08:46:38+00:00\",\"description\":\"Basic MySQL database administration on a Linux VPS - RoseHosting\",\"breadcrumb\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/#primaryimage\",\"url\":\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2014\/09\/mysql.png\",\"contentUrl\":\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2014\/09\/mysql.png\",\"width\":390,\"height\":201},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.rosehosting.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Basic MySQL database administration on a Linux VPS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#website\",\"url\":\"https:\/\/www.rosehosting.com\/blog\/\",\"name\":\"RoseHosting\",\"description\":\"Premium Linux Tutorials Since 2001\",\"publisher\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.rosehosting.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#organization\",\"name\":\"RoseHosting\",\"url\":\"https:\/\/www.rosehosting.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png\",\"contentUrl\":\"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png\",\"width\":192,\"height\":192,\"caption\":\"RoseHosting\"},\"image\":{\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/RoseHosting\",\"https:\/\/x.com\/rosehosting\",\"https:\/\/www.linkedin.com\/in\/rosehosting\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713\",\"name\":\"Jeff Wilson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/09271207587f897ab46faaed9b355252?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/09271207587f897ab46faaed9b355252?s=96&r=g\",\"caption\":\"Jeff Wilson\"},\"description\":\"An experienced Linux veteran with many years of experience. Helping other Linux admins with frequent Linux and business-related blog posts on the RoseHosting blog. Techie by choice. Loving nature and travel. Happily married and father of two lovely children.\",\"sameAs\":[\"https:\/\/www.rosehosting.com\",\"https:\/\/www.facebook.com\/rosehosting.helpdesk\"],\"url\":\"https:\/\/www.rosehosting.com\/blog\/author\/jwilson\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Basic MySQL database administration on a Linux VPS - RoseHosting","description":"Basic MySQL database administration on a Linux VPS - RoseHosting","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/","og_locale":"en_US","og_type":"article","og_title":"Basic MySQL database administration on a Linux VPS - RoseHosting","og_description":"Basic MySQL database administration on a Linux VPS - RoseHosting","og_url":"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/","og_site_name":"RoseHosting","article_publisher":"https:\/\/www.facebook.com\/RoseHosting","article_author":"https:\/\/www.facebook.com\/rosehosting.helpdesk","article_published_time":"2014-10-10T19:21:29+00:00","article_modified_time":"2022-06-03T08:46:38+00:00","og_image":[{"width":390,"height":201,"url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2014\/09\/mysql.png","type":"image\/png"}],"author":"Jeff Wilson","twitter_card":"summary_large_image","twitter_creator":"@rosehosting","twitter_site":"@rosehosting","twitter_misc":{"Written by":"Jeff Wilson","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/#article","isPartOf":{"@id":"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/"},"author":{"name":"Jeff Wilson","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713"},"headline":"Basic MySQL database administration on a Linux VPS","datePublished":"2014-10-10T19:21:29+00:00","dateModified":"2022-06-03T08:46:38+00:00","mainEntityOfPage":{"@id":"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/"},"wordCount":526,"commentCount":0,"publisher":{"@id":"https:\/\/www.rosehosting.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/#primaryimage"},"thumbnailUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2014\/09\/mysql.png","keywords":["mysql"],"articleSection":["Databases","Tips and Tricks","Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/","url":"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/","name":"Basic MySQL database administration on a Linux VPS - RoseHosting","isPartOf":{"@id":"https:\/\/www.rosehosting.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/#primaryimage"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/#primaryimage"},"thumbnailUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2014\/09\/mysql.png","datePublished":"2014-10-10T19:21:29+00:00","dateModified":"2022-06-03T08:46:38+00:00","description":"Basic MySQL database administration on a Linux VPS - RoseHosting","breadcrumb":{"@id":"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/#primaryimage","url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2014\/09\/mysql.png","contentUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2014\/09\/mysql.png","width":390,"height":201},{"@type":"BreadcrumbList","@id":"https:\/\/www.rosehosting.com\/blog\/basic-mysql-database-administration-on-a-linux-vps\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.rosehosting.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Basic MySQL database administration on a Linux VPS"}]},{"@type":"WebSite","@id":"https:\/\/www.rosehosting.com\/blog\/#website","url":"https:\/\/www.rosehosting.com\/blog\/","name":"RoseHosting","description":"Premium Linux Tutorials Since 2001","publisher":{"@id":"https:\/\/www.rosehosting.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.rosehosting.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.rosehosting.com\/blog\/#organization","name":"RoseHosting","url":"https:\/\/www.rosehosting.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png","contentUrl":"https:\/\/www.rosehosting.com\/blog\/wp-content\/uploads\/2022\/03\/android-chrome-192x192-1.png","width":192,"height":192,"caption":"RoseHosting"},"image":{"@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/RoseHosting","https:\/\/x.com\/rosehosting","https:\/\/www.linkedin.com\/in\/rosehosting\/"]},{"@type":"Person","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/7ce77a842fa6a9a7f8efa186f2353713","name":"Jeff Wilson","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.rosehosting.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/09271207587f897ab46faaed9b355252?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/09271207587f897ab46faaed9b355252?s=96&r=g","caption":"Jeff Wilson"},"description":"An experienced Linux veteran with many years of experience. Helping other Linux admins with frequent Linux and business-related blog posts on the RoseHosting blog. Techie by choice. Loving nature and travel. Happily married and father of two lovely children.","sameAs":["https:\/\/www.rosehosting.com","https:\/\/www.facebook.com\/rosehosting.helpdesk"],"url":"https:\/\/www.rosehosting.com\/blog\/author\/jwilson\/"}]}},"_links":{"self":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/4774"}],"collection":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/comments?post=4774"}],"version-history":[{"count":1,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/4774\/revisions"}],"predecessor-version":[{"id":36643,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/posts\/4774\/revisions\/36643"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/media\/4670"}],"wp:attachment":[{"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/media?parent=4774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/categories?post=4774"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rosehosting.com\/blog\/wp-json\/wp\/v2\/tags?post=4774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}