Ali cloud server new user specific method
- 2020-06-01 11:08:48
- OfStack
1. New server user:
User management, the main work is to establish a legitimate user account, set and manage the user's password, modify the user account properties and when necessary to delete the user account has been abandoned.
1) add a new user
In the Linux system, only root users can create a new user. The following command will create a new user with the login name user1.
#useradd user1
However, this user is not yet able to log in because an initial password has not been set to it, and users who do not have a password are not able to log in to the system. By default, a new user home directory with the same username will be created in the /home directory.
In Linux, when a new user is added, a new group is created with the same name as the user, and the user is a member of the group. If you want a new user to belong to an existing group, you can use the following command:
#useradd -g usergroup1 user1
This makes the user a member of the usergroup1 group. If you want it to belong to another group usergroup2, you can use:
#useradd -G usergroup2 user1
Once you've done this, you should also set an initial password for it using the passwd command.
2) delete 1 user
To delete the user, simply use a simple command "userdel user name". However, it is better to delete the files left on the system as well. You can use the "userdel-r username" to do this.
3) add one group
We can create user groups according to our own needs:
groupadd < Group name >
4) delete 1 group
Similarly, we sometimes need to delete a group whose command is groupdel.
2. Install mysql and create mysql users:
1.[root@test1 local]# yum -y install mysql mysql-server
This command installs both the mysql client and the mysql server
2. Test whether it is successful to run netstat and see if the Mysql port is open. If it is open, it means that the service has been started and the installation is successful. The default port for Mysql 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 display shows that the MySQL service has been started.
3. The command to log on to MySQL is mysql
On the first entry, just type mysql.
[root@test1 local]# mysql
The login format after adding the password is as follows:
mysql -u root -p
Enter password: (enter password)
3. Several important directories of MySQL
1). Database directory
/var/lib/mysql/
2). Configuration files
/usr/share/mysql (mysql.server command and configuration files)
3) relevant commands
/usr/bin(mysqladmin mysqldump, etc.)
4) start the script
/ etc rc. d/init. d/(mysqld startup script file directory)
4. Change your password
1) command
usr/bin/ mysqladmin-u root password 'new-password'
Format: mysqladmin-u username -p old password password new password
Example 2)
Example 1: add password 123456 to root.
Type the following command:
[root@test1 local]# /usr/bin/mysqladmin -u root password 123456
Note: since root does not have a password at the beginning, the old password 1 entry for -p can be omitted.
3) test whether the modification is successful
< 1 > Login without 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 changed.
< 2 > Log in with the changed password
[root@test1 local]# mysql -u root -p
Enter password: (enter the modified password 123456)
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 >
Success!
This is done by changing the password with the mysqladmin command, or by changing the library.
5. Add MySQL users
grant all on *.* to 'xhx'@'%' Identified by '123456';
Users with the above grant permissions can access your MySQL database from any computer on the web and do whatever they want with your data.
User management, the main work is to establish a legitimate user account, set and manage the user's password, modify the user account properties and when necessary to delete the user account has been abandoned.
1) add a new user
In the Linux system, only root users can create a new user. The following command will create a new user with the login name user1.
#useradd user1
However, this user is not yet able to log in because an initial password has not been set to it, and users who do not have a password are not able to log in to the system. By default, a new user home directory with the same username will be created in the /home directory.
In Linux, when a new user is added, a new group is created with the same name as the user, and the user is a member of the group. If you want a new user to belong to an existing group, you can use the following command:
#useradd -g usergroup1 user1
This makes the user a member of the usergroup1 group. If you want it to belong to another group usergroup2, you can use:
#useradd -G usergroup2 user1
Once you've done this, you should also set an initial password for it using the passwd command.
2) delete 1 user
To delete the user, simply use a simple command "userdel user name". However, it is better to delete the files left on the system as well. You can use the "userdel-r username" to do this.
3) add one group
We can create user groups according to our own needs:
groupadd < Group name >
4) delete 1 group
Similarly, we sometimes need to delete a group whose command is groupdel.
2. Install mysql and create mysql users:
1.[root@test1 local]# yum -y install mysql mysql-server
This command installs both the mysql client and the mysql server
2. Test whether it is successful to run netstat and see if the Mysql port is open. If it is open, it means that the service has been started and the installation is successful. The default port for Mysql 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 display shows that the MySQL service has been started.
3. The command to log on to MySQL is mysql
On the first entry, just type mysql.
[root@test1 local]# mysql
The login format after adding the password is as follows:
mysql -u root -p
Enter password: (enter password)
3. Several important directories of MySQL
1). Database directory
/var/lib/mysql/
2). Configuration files
/usr/share/mysql (mysql.server command and configuration files)
3) relevant commands
/usr/bin(mysqladmin mysqldump, etc.)
4) start the script
/ etc rc. d/init. d/(mysqld startup script file directory)
4. Change your password
1) command
usr/bin/ mysqladmin-u root password 'new-password'
Format: mysqladmin-u username -p old password password new password
Example 2)
Example 1: add password 123456 to root.
Type the following command:
[root@test1 local]# /usr/bin/mysqladmin -u root password 123456
Note: since root does not have a password at the beginning, the old password 1 entry for -p can be omitted.
3) test whether the modification is successful
< 1 > Login without 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 changed.
< 2 > Log in with the changed password
[root@test1 local]# mysql -u root -p
Enter password: (enter the modified password 123456)
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 >
Success!
This is done by changing the password with the mysqladmin command, or by changing the library.
5. Add MySQL users
grant all on *.* to 'xhx'@'%' Identified by '123456';
Users with the above grant permissions can access your MySQL database from any computer on the web and do whatever they want with your data.