How to run MySQL_MySQL as a common user

Source: Internet
Author: User
How can I run MySQLbrMySQL server as a general user? mysqld can be started and run by any user. To change mysqld to user_name, a Unix user, you must do the following: if it is running, stop the server (using mysqladminshutdown ). Br change the Database Directory and file so that user_name has the permission to read and write files (you may need to run MySQL as a general user
MySQL server mysqld can be started and run by any user. To change mysqld to user_name, a Unix user, you must do the following:
  
If it is running, stop the server (use mysqladmin shutdown ).
Change the Database Directory and file so that user_name has the permission to read and write files (you may need to be a Unix root user ):
Shell> chown-R user_name/path/to/mysql/datadir
  
If the directory or file in the MySQL data directory is a symbolic link, you will also need to follow those links and change the directories and files they direct. Chown-R cannot follow the symbolic link.
  
Start the server as user_name, or if you are using MySQL 3.22 or later, start mysqld as a Unix root user and use the -- user = user_name option, mysqld will switch to run as a Unix user_name user before accepting any connection.
If you use the mysql. server script to start mysqld when the system is restarted, you should edit mysql. server and run mysqld with user user_name using su, or call mysqld using the -- user option. (It is necessary not to change safe_mysqld .)
Now, your mysqld process should be running properly as the Unix user_name user. Although one thing remains unchanged: the content of the permission table. By default (after the permission table installed by the script mysql_install_db is run), the MySQL User root is the only user with the permission to access the mysql database or create or discard the database. Unless you change those permissions, they will remain. When you log on as a Unix user rather than the root user, this should not prevent you from accessing MySQL as the MySQL root user; you only need to specify the-u root option for the client program.
  
Note that-u root is provided on the command line to access MySQL as root. it does not matter if MySQL is run as Unix root or other Unix users. The access permissions and user names of MySQL are completely separated from those of Unix users. The only thing related to the Unix user name is that if you do not provide a-u option when calling a client program, the customer will try to use your Unix login name as your MySQL User name for connection.
  
If your Unix machine is not secure, you should at least put a password for the MySQL root user in the access table. Otherwise, any user with an account on that machine can run mysql-u root db_name and do whatever he prefers.
Related Article

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.