Installation of tar-free MySQL Configuration

Source: Internet
Author: User
Tags mysql manual
Installation of tar-free MySQL Configuration
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 http://www.mysql.com

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 by adding-Prefix =/usr/loal/MySQL during source code configure, the tar package can be directly decompressed 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 mysql-R
$ Chown MySQL 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.

 

Reference: http://www.linuxdiyf.com/bbs/thread-107248-1-1.html

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.