How to create a user on an Alibaba Cloud Server

Source: Internet
Author: User

1. Create a server user:
 
The main task of user management is to create a legal user account, set and manage user passwords, modify user account attributes, and delete obsolete user accounts when necessary.

1) Add a new user

In Linux, only the root user can create a new user. The following command creates a user with the login name user1.

# Useradd user1

However, this user is not allowed to log on, because the initial password has not been set for it, and users without a password cannot log on to the system. By default, a user home directory with the same user name will be created in the/home directory.

In Linux, when a user is added, a new group is created. The Group has the same name as the user, and the user is a member of the group. To assign a new user to an existing group, run the following command:

# Useradd-g usergroup1 user1

In this way, the user is a member of usergroup1. If you want to make it belong to another group of usergroup2, use:

# Useradd-G usergroup2 user1

After completing this operation, you should also use the passwd command to set an initial password for it.

2) delete a user

To delete a user, you only need to use a simple command "userdel user name. However, it is best to delete the files that remain on the system. You can use "userdel-r username" to achieve this purpose.

3) Add a group

You can create user groups as needed:

Groupadd <Group Name>

4) delete a group

Similarly, we sometimes need to delete a group. Its command is groupdel.

2. Install mysql and create mysql users:
 
1. [root @ test1 local] # yum-y install mysql-server
This command installs both the mysql client and the mysql server

2. Check whether the test is successful. Run netstat to check whether the Mysql port is opened. If yes, the service is started and the installation is successful. The default Mysql port is 3306.
[Root @ test1 local] # netstat-nat

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
Tcp 0 0 0.0.0.0: 3306 0.0.0.0: * LISTEN
The above shows that the MySQL service has been started.

3. The command for logging on to MySQL is mysql.

For the first entry, you only need to type mysql.
[Root @ test1 local] # mysql

The logon format after the password is added is as follows:
Mysql-u root-p
Enter password: (Enter the password)

3. Several important MySQL Directories

1). Database directory
/Var/lib/mysql/

2). Configuration File
/Usr/share/mysql (mysql. server command and configuration file)

3) related commands
/Usr/bin (commands such as mysqladmin mysqldump)

4) Start the script
/Etc/rc. d/init. d/(directory of mysqld STARTUP script file)

4. Change the logon Password

1) command
Usr/bin/mysqladmin-u root password 'new-password'
Format: mysqladmin-u username-p old password New password

2) Example
Example 1: Add a 123456 password to the root user.
Type the following command:
[Root @ test1 local] #/usr/bin/mysqladmin-u root password 123456
Note: because the root account does not have a password at the beginning, the old-p password can be omitted.

3) test whether the modification is successful
<1> logon without a password
[Root @ test1 local] # mysql
ERROR 1045: Access denied for user: 'root @ localhost' (Using password: NO)
An error is displayed, indicating that the password has been modified.
<2> Log On with the modified Password
[Root @ test1 local] # mysql-u root-p
Enter password: (Enter the password 123456 after modification)
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 4 to server version: 4.0.16-standard
Type 'help; 'or' \ H' for help. Type '\ C' to clear the buffer.
Mysql>
Successful!
You can use the mysqladmin command to change the password or the database to change the password.

5. Added MySQL users.

Grant all on *. * to 'xhx '@' % 'Identified by '123 ';

After the above grant permissions, users can log on to your MySQL database on any computer on the Internet and do whatever they want for your data.

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.