How to install a MySQL database in a Unix System

Source: Internet
Author: User

We recommend that you create a user and group for MySQL management during installation. This group of users runs the mysql server and executes management tasks. (You can also run the server as root, but it is not recommended)

Step 1 create a user to run the server. In Solaris and unix, you can use useradd and groupadd tools. Name it mysql. (Of course, any id you like) So before doing other things, use the su command to become root:

  

$ Su-root

  

$ Groupadd mysql

  

$ Useradd-g mysql


Select the location where you want to install the mysql software and convert the current directory to this directory. Generally, install it to/usr/local, which is the standard installation location of MySQL software. Go in now,


$ Cd/usr/local
 

Unpack the software package:
 

$ Gunzip-c/tmp/mysql -3.23.xx.tar.gz tar-xf-

  

Because it is installed on the Solaris server, if tar of different versions, such as GNU tar, is installed, the above command will not work. Use the following command:

  

$ Gunzip-c/tmp/mysql -3.23.xx.tar.gz gtar-xf-

  

Now you can check the new directory to see if it exists.

  

$ Ls-ld mysql *

  

Total 1

  

Drwxr-xr-x 28 user 1024 Jul 18 mysql-3.23.x/

  

The next step is to create a symbolic link so that the installation can point to/usr/local/mysql:

  

$ Ln-s mysql-3.23.x mysql

  

$ Ls-ld mysql *

  

The connection is successful. After the software is installed, several configuration tasks need to be completed. Run scripts/mysql_install_db to create the MySQL license table:

  

$ Scripts/mysql_install_db

  

Preparing db talbe

  

Preparing host table

  

Preparing user table

  

Preparing func table

  

Preparing tables_priv table

  

Preparing columns_priv table

  

Installing all prepared tables

  

010726 19:40:05./bin/mysqld: Shutdown Complete

  

Set the ownership of the binary file, so that it belongs to the root, and belongs to the MySQL

  

Administrator group (mysql in this example)

  

$ Chown-R root/usr/local/mysql

  

$ Chgrp-R mysql/usr/local/mysql

  

Set the ownership of the data directory to the MySQL Administrator created earlier.

  

$ Chown-R mysql/usr/local/mysql/data

  

Ownership settings complete

  

To start the server, run safe_mysqld:

  

$ Bin/safe_mysqld -- usr = mysql &

  

MySQL is usually required to run during server boot. To this end, you can copy support-files/mysql. server to the appropriate system location.

  

  

  

To ensure that MySQL works properly, you need to run some simple tests. if the output result is BINDIR =/usr/local/mysql/bin, it indicates that MySQL works normally. the value of BINDIR is related to the prefix option selected above.

  

  

--------------------------------------------------------------------------------

  

# BINDIR/mysqlshow-p

  

+ --------------- +

  

Databases

  

+ --------------- +

  

Mysql

  

+ --------------- +

  

--------------------------------------------------------------------------------

  

Once you install MySQL, it will automatically generate two databases. One is used to manage user, host, and server database permissions. The other is test database ). We can use the test database. However, we want to give you a brief overview of some of the available commands in MySQL. This also ensures that the root user can be set to have full access to the server. For example, root can allow the user to create databases and forms. Therefore, we will create a test2 database for future testing. Before entering MySQL through commands, the system will prompt you to enter the newly created root password. Remember that you have changed the root password.

  

--------------------------------------------------------------------------------

  

# Mysql-u root-p

  

Mysql> show databases;

  

+ ---------------- +

  

Database

  

+ ---------------- +

  

Mysql

  

Test

  

+ ---------------- +

  

Mysql> create database test2;

  

Query OK, 1 row affected (0.00 sec)

  

--------------------------------------------------------------------------------

  

Use the following two pieces of code to select a new database and create a table named tst_tbl. It has two fields. The first field (field 1) is the id field, through which you can see the id of the record. Essentially, this is only a column of pure numbers. The second field is the name field, in which the name of the book can be stored. The format of these fields is: field 1 (id) is an integer (int) with a length of 3, and field 2 (name) is a string (char) with a length of 50 ). We can assign values to IDs to search and index data.

  • 2 pages in total:
  • Previous Page
  • 1
  • 2
  • Next Page

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.