R1-004 如何啟用MySQL的rpm安裝方式的Shell
用root使用者安裝MySQL後,會自動建立一個名為mysql的組和一個名為mysql的系統使用者,但是無法從root使用者切換到mysql使用者:
[root@hhu MySQL]# su - mysql
[root@hhu MySQL]# su - mysql
原因是剛剛安裝的mysql使用者的Shell設定問題,可以從/etc/passwd檔案看出
[root@hhu home]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/cache/rpcbind:/sbin/nologin
vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
rtkit:x:499:497:RealtimeKit:/proc:/sbin/nologin
avahi-autoipd:x:170:170:Avahi IPv4LL Stack:/var/lib/avahi-autoipd:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
saslauth:x:498:76:"Saslauthd user":/var/empty/saslauth:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
apache:x:48:48:Apache:/var/www:/sbin/nologin
haldaemon:x:68:68:HAL daemon:/:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
pulse:x:497:495:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
oprofile:x:16:16:Special user account to be used by OProfile:/home/oprofile:/sbin/nologin
hhu:x:500:500:hhu:/home/hhu:/bin/bash
vboxadd:x:496:1::/var/run/vboxadd:/bin/false
oracle:x:501:502::/home/oracle:/bin/bash
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/false
可以看到,mysql使用者的Shell屬性是/bin/false,這意味著:false - do nothing, unsuccessfully。可用usermod命令來修改mysql使用者的Shell屬性,解鎖Shell。
[root@hhu home]# usermod -s /bin/bash mysql
[root@hhu home]# su - mysql
-bash-4.1$ cd
-bash-4.1$ ls
auto.cnf ib_logfile0 performance_schema
ca-key.pem ib_logfile1 private_key.pem
ca.pem ibtmp1 public_key.pem
client-cert.pem mysql server-cert.pem
client-key.pem mysqld_safe.pid server-key.pem
ib_buffer_pool mysql.sock sys
ibdata1 mysql.sock.lock
-bash-4.1$ pwd
/var/lib/mysql
-bash-4.1$ echo $HOME
/var/lib/mysql
[root@hhu MySQL]# su - mysql
[root@hhu MySQL]# su - mysql
原因是剛剛安裝的mysql使用者的Shell設定問題,可以從/etc/passwd檔案看出
[root@hhu home]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/cache/rpcbind:/sbin/nologin
vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
rtkit:x:499:497:RealtimeKit:/proc:/sbin/nologin
avahi-autoipd:x:170:170:Avahi IPv4LL Stack:/var/lib/avahi-autoipd:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
saslauth:x:498:76:"Saslauthd user":/var/empty/saslauth:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
apache:x:48:48:Apache:/var/www:/sbin/nologin
haldaemon:x:68:68:HAL daemon:/:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
pulse:x:497:495:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
oprofile:x:16:16:Special user account to be used by OProfile:/home/oprofile:/sbin/nologin
hhu:x:500:500:hhu:/home/hhu:/bin/bash
vboxadd:x:496:1::/var/run/vboxadd:/bin/false
oracle:x:501:502::/home/oracle:/bin/bash
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/false
可以看到,mysql使用者的Shell屬性是/bin/false,這意味著:false - do nothing, unsuccessfully。可用usermod命令來修改mysql使用者的Shell屬性,解鎖Shell。
[root@hhu home]# usermod -s /bin/bash mysql
[root@hhu home]# su - mysql
-bash-4.1$ cd
-bash-4.1$ ls
auto.cnf ib_logfile0 performance_schema
ca-key.pem ib_logfile1 private_key.pem
ca.pem ibtmp1 public_key.pem
client-cert.pem mysql server-cert.pem
client-key.pem mysqld_safe.pid server-key.pem
ib_buffer_pool mysql.sock sys
ibdata1 mysql.sock.lock
-bash-4.1$ pwd
/var/lib/mysql
-bash-4.1$ echo $HOME
/var/lib/mysql
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29067253/viewspace-2134151/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Linux下用rpm方式安裝MySQLLinuxMySql
- MySQL 5.7.22 rpm 安裝方式MySql
- MySQL之——RPM方式安裝MySQL5.6MySql
- puppet rpm方式的安裝
- R1-002 MySQL的rpm安裝方式MySql
- CentOS安裝MySQL的兩種方式——RPM和YUMCentOSMySql
- mysql cluster 7.38 叢集安裝 rpm安裝方式MySql
- centos7下rpm方式安裝mysqlCentOSMySql
- CentOS 6 下RPM方式安裝MySQL5.6CentOSMySql
- Percona MySQL 5.6 RPM包方式安裝流程MySql
- mysql安裝(rpm)MySql
- yum如何解除安裝已安裝的rpm並安裝本地rpm包
- XtraBackup 用rpm的安裝方法
- MySQL 5.6 RPM安裝MySql
- centos以RPM包方式安裝redis的方法CentOSRedis
- 在Linux(Redhat/CentOS)下安裝MySQL之yum(rpm)線上安裝方式LinuxRedhatCentOSMySql
- rpm方式安裝redis4.0Redis
- clickhouse-backup(RPM方式安裝)
- mysql安裝------RPM包安裝及解除安裝MySql
- 在Linux(Redhat/CentOS)下安裝MySQL之yum(rpm)離線安裝方式LinuxRedhatCentOSMySql
- suse rpm安裝mysql(轉)MySql
- suse rpm 安裝 mysql(轉)MySql
- Linux rpm安裝MySQLLinuxMySql
- Linux平臺(CentOS 6.5) RPM包方式安裝 Mysql 5.7LinuxCentOSMySql
- mysql8.0.30的RPM包安裝方法MySql
- 使用rpm安裝mysql的預設目錄MySql
- rpm方式離線安裝ansible
- RPM方式安裝oracle資料庫Oracle資料庫
- rpm包方式安裝Percona serverServer
- mysql rpm 安裝問題(轉)MySql
- Mysql for Linux安裝配置之—— rpm(bundle)安裝MySqlLinux
- R1-003 MySQL的rpm安裝例項MySql
- R1-004 Shell命令種類
- CentOS下使用rpm包安裝MySQLCentOSMySql
- mysql 5.6 for linux (rpm包安裝)MySqlLinux
- MySQL-Cluster7.3.6-2 rpm安裝MySql
- rpm 安裝5.6 MySql主從搭建MySql
- 基於Linux的MySQL5.7RPM包安裝LinuxMySql