Installation of tar-free MySQL Configuration

Source: Internet
Author: User
At the same time, a version has different distribution forms. Some use rpm packages, some use tar packages, and some use source code. Rpm package is easy to install, but not flexible enough; source generation

At the same time, a version has different distribution forms. Some use rpm packages, some use tar packages, and some use source code. Rpm package is easy to install, but not flexible enough; source generation

I encountered many problems when installing MYSQL in the past two days. I found a lot of materials and wrote out the summary.

1. select an appropriate mysql version. Go

The latest mysql version

At the same time, a version has different distribution forms. Some use rpm packages, some use tar packages, and some use source code. The rpm package is easy to install, but not flexible enough; the source code is flexible but requires compilation, So I downloaded the tar package for installation because it has been optimized for compilation. Generally, you can decompress the tar package directly, but you still need to modify some links for ease of start and stop!

2. Install mysql.

The rpm package installation is not described in detail. It is best to install the source code and tar package in/usr/local/mysql ,, the method is to add-prefix =/usr/loal/mysql to the source code configure, and directly extract the tar package to/usr/local/mysql.

3. Configure after installation.

Find/bin/mysql_install_db In the mysql directory (after installation) and run it. The tar package is in the script s directory of mysql, so that the database is installed:
$ Cd/usr/local/mysql
$./Bin/mysql_install_db (initialize database)

Add a group of mysql and user mysql, set its initial directory to the installation directory of mysql, and set mysql to the owner of the mysql folder, so as to prevent the failure to connect to the MySql server from errors:
$ Useradd-M-o-r-d/usr/local/mysql-s/bin/bash-c "mysql user"-u 27 mysql
$ Cd/usr/local/
$ Chmod 750 mysql-R
$ Chgrp mysql-R
$ Chown mysql-R

Run the/bin/mysql_safe command in the mysql directory. The tar package has a shell file named safe_mysql. In this way, the mysql daemon starts to run:
$/Usr/local/mysql/bin/safe_mysqld &

Check port 3306 of the network to determine whether mysql is running properly:
$ Netstat-atln

If it does not run properly, go to the data directory to view the log file query error.

To facilitate the process, create several linked files to/sbin to avoid running the program in mysql every time:
$ Ln-s/usr/local/mysql/bin/mysql/sbin/mysql
$ Ln-s/usr/local/mysql/bin/mysqladmin/sbin/mysqladmin

Copy the daemon script to the initialization directory and add it to the Auto Start List:
$ Cd mysql
$ Cp support-files/mysql. server/etc/rc. d/init. d/mysqld

$ Modify the directory of pid_file in mysqld! Of course, the directory should be the same as the started PID directory.
$ Chkconfig-add mysqld
$ Chkconfig-level 345 mysqld on

Verify the correctness of the preceding operations. Run:
$/Etc/rc. d/init. d/mysqld restart
Or:
$ Service mysqld restart

4. mysql Security Settings

Run the following command to clear the empty password account:
$ Mysqladmin-uroot password "youpassword" # Set the password of the root account
$ Mysql-uroot-p

Mysql> use mysql;
Mysql> delete from user where password = ""; # delete an empty password account used for anonymous local connection
Mysql> flush privileges;
Mysql> quit

Finally, let's test it, but first switch to the msql-benmak directory in mysql:
$ Perl run-all-tests-user = root-password = "new"

To write programs to access the mysql database, you should create a link to the include and lib directories of mysql in/usr/include and/usr/lib, in this way, you only need to add # include to the program to reference the mysql header file.
Ln-s/usr/local/mysql/lib/mysql/usr/lib/mysql
Ln-s/usr/local/mysql/include/mysql/usr/include/mysql

The path, file, and folder names are modified based on your situation. For example, the include directory in my tar package does not have the mysql folder, and there are only many header files, so I wrote it like this:
Ln-s/usr/local/mysql/lib/usr/lib/mysql
Ln-s/usr/local/mysql/include/usr/include/mysql

However, in any case, the header file can be referenced normally.

Some of them are flexible and flexible. If you do not consider other factors, your mysql can be installed in the root directory, but you usually put it in the/usr/local/mysql directory.

4. Install the perl Module

Many Web pages still use perl. In order to access mysql using the perl language and run the test program attached to mysql, I installed some perl modules.

In this regard, there are different arguments. In fact, you do not need to install the installation industry. Some users do not need to install php for web applications. For example, I only need to write applications to access mysql, But I have installed it, only to test mysql.

My installed modules include:
Data-Dumper 2.121
Data-ShowTable-3.3
DBD-mysql-2.9003
DBI-1.42
Msql-Mysql-modules-1.2219
Net-MySQL-0.08

We recommend Data-Dumper + Data-ShowTable + DBI + Msql-mysql-modules in the Mysql manual, so that DBI is successfully installed. However, the DBI module recommended on the mysql website only contains DBI + Net-MySQL + DBD-mysql. I am not familiar with perl, I don't know what the use of such a pm file is, but I am sure that there is no harm in installing such a module.

During the installation process, the Data-ShowTable 724 line code encountered an error, obviously missing two ">", and DBD-mysql compilation also encountered an error because the path is incorrect, the mysql-config file is not found. You can add your path to the compilation file.

Other compilation operations can be performed according to readme.

5. Management Tools

After installation, you can add your own items to the database.

Are you still using the command line? Anyway, I am a big leader. I think you only need to know about it. As for practical applications, you can use some good GUI tools. After all, the programmer's mission is to make computers closer to people. What do they do?

As for mysql management tools, I recommend mysqlcc, which is very easy to use. Although it is uncomfortable to use in some places, you can change it if you are interested. After all, this is an open-source advantage.

Create a soft connection in/usr/bin:
Ln-s/usr/local/mysqlcc/usr/bin/mysqlcc

So, Use it anywhere!

6. Add a remote user

To allow remote users to access the database, add remote users.
$ Mysql-p
Enter password :*****
Mysql> use mysql
Mysql> grant all privileges on *. * to test @ "192.168.0. %" identified by "test" with grant option;
Mysql> quit;

In this way, a Super User test is created, which can be connected anywhere in the local LAN. The permission is very large, but the password is very poor. We don't want to do this, but at this time, the user's permissions have already taken effect.

If you manually modify the authorization table, you must:
Mysql> flush privileges;
Or
$ Mysqladmin flush-privileges-p

In addition, the change of global permissions and password take effect the next time the customer connects, the table and column permissions take effect the next time the customer requests, and the change of database permissions takes effect in the next USE db_name command.

Use mysqlcc to modify the permissions of the test user. Because I don't want this user to destroy my data, it is in the user table.

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.