Create a MySQL instance in the LNMP environment

Source: Internet
Author: User
1InstallMySQLroot @ kallen :~ Apt-getinstallmysql-server-55mysql-client-552AddUsers (1) select the data table statement as follows: usemysql; (2) add a connection user account in the mysql user table: do not 1. Install MySQL

root@kallen:~# apt-get install mysql-server-5.5 mysql-client-5.5

2.Add Users

(1) select a data table
Statement: use mysql;
(2) add a connection user account in the mysql user table:
Here, do not directly use the INSERT statement to add user records. an error may occur when using INSERT:

ERROR 1364 (HY000): Field ‘ssl_cipher’ doesn’t have a default value

However, this error did not occur in earlier MYSQL versions, because the user table has been directly modified or the INSERT statement has been directly used. when MYSQL is upgraded to MYSQL 5.1, this error may occur.
We recommend that you use the GRANT statement for authorization. The statement is as follows:

GRANT USAGE ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

Last sentence:

Replace "username" with the user name to be authorized, such as clientusr;
Replace "password" with the password set by clientusr;

(3) Data Table access authorization

After the account is created, authorize the preceding common user to the data table. the default permissions of the connected user added in step 3 are "N" and must be authorized for the account in the db table, allow the user to access the dedicated database. of course, the super user will not talk about it.

Use the following statement:

GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON tablename.* TO 'username'@'localhost' IDENTIFIED BY 'password';

The permissions in this statement are determined based on actual needs:

Replace "tablename" with the table name of the authorized data table
"Username" is the username authorized in step 2.
"Password" is the password set for step 2 authorized users

This grants the SELECT, INSERT, UPDATE, DELETE, CAREATE, and DROP permissions to a data table.

(4) effective authorization, created

One sentence: flush privileges;

3.Install phpmyadmin

Download and install phpmyadmin on any web server that supports PHP (such as Apache, Nginx, and Lighttpd.

Sudo apt-get install phpmyadmin # note that this is installed in/usr/share/phpmyadmin

In ubuntu, sudo apt-getinstall phpmyadmin has some settings, such as server selection and password setting. After the installation is complete, the 404 error occurs when you access http: // localhost/phpmyadmin. this is because the phpmyadmin directory is not mapped to the apache Directory. run the following command:

sudo ln -s /usr/share/phpmyadmin /var/www/html

[Common errors]

(1) installation error:

Error: Package: php54w-tidy-5.4.41-1.w6.x86_64 (webtatic) Requires: libtidy-0.99.so.0()(64bit) You could try using --skip-broken to work around the problem You could try running: rpm -Va --nofiles --nodigest 

Need to install libtidy-0.99.so:

[root@amtt02 html]# rpm -ivh libtidy-0.99.0-19.20070615.1.el6.x86_64.rpm

(2) access error:
Add the following to the http. conf file:

  AllowOverride None Order allow,deny Allow from all  
service httpd restart 

Then, the httpd service can be started successfully and the problem is solved.

Prompt for accessing phpMyAdmin:

The configuration file permission is incorrect and cannot be written!

Solution:

chmod -R 755 ./phpmyadmin

In this way, The phpMyAdmin directory permission attribute is set to 755. It turns out that phpMyAdmin can run only with the 755 permission.

Note: It is also incorrect in 777. it is estimated that phpMyAdmim is safe.

4.Can’t connect to MySQL server on ‘localhost’(10038)

Check whether remote connection is allowed in your MYSQL User table.

(1) authorize the user

mysql>grant all privileges on *.*to'root'@'%' identified by 'youpassword' with grant option;
mysql>flush privileges;

(2) modify/etc/mysql/my. conf

Find bind-address = 127.0.0.1.
Change bind-address = 0.0.0.0.

root@kallen:/etc/selinux# vim /etc/mysql/# Instead of skip-networking the default is now to listen only on# localhost which is more compatible and is not less secure.# bind-address = 127.0.0.1# Remote Access to MySQL on port 3306# Kallen Ding, Jun 11 2015bind-address = 0.0.0.0

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.