Ubuntu Install MySQL Step

Source: Internet
Author: User

The general installation of software in Ubuntu only requires a few commands, installation of MySQL is also, the following steps:

1, in order to get the latest installation package, first update the list of packages

sudo apt-get update

2. Install MySQL server

sudo apt-get install Mysql-server

Appear as: Set the password, and then re-enter the password, OK.

3. Install the MySQL client

sudo apt-get install mysql-client

4. Install MySQL Library

sudo apt-get install Libmysqlclient-dev

5. Check whether the installation is successful

sudo netstat-tap | grep MySQL

Appears as: MySQL socket in Listen state indicates successful installation.

6. Log in to MySQL database

mysql-u root-p ( - u indicates the login user name, and-p indicates the login user password. )

7. View current Database

show databases; (note plus semicolon)

8. Choose to use MySQL Library

Use MySQL

9. Display the current data form

Show tables; (note plus semicolon)

10, MySQL C program implementation of Show Tables function

 #include <    mysql/mysql.h> #include <stdio.h> #include <stdlib.h>int main () {MySQL *conn;    Mysql_res *res;    Mysql_row ROW;    Char server[] = "localhost";    Char user[] = "root";        Char password[] = "password";//password set when MySQL is installed char database[] = "MySQL";        conn = Mysql_init (NULL); if (!mysql_real_connect (conn, server,user, password, database, 0, NULL, 0)) {fprintf (stderr, "%s\n", Mysql_err        OR (conn));    Exit (1);        } if (mysql_query (conn, "Show Tables")) {fprintf (stderr, "%s\n", MYSQL_ERROR (conn));    Exit (1);        } res = Mysql_use_result (conn);        printf ("MySQL Tables in MySQL database:\n");    while (row = mysql_fetch_row (res)) = NULL) {printf ("%s \ n", row[0]);    } mysql_free_result (res);        Mysql_close (conn); printf ("finish!    \ n "); return 0;} 

Compilation: Gcc-wall Mysql_test.c-o mysql_test-lmysqlclient

The result of the operation is as follows: The show tables command output above.

Ubuntu Install MySQL Step

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.