In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
For the first time, when you learn to configure Mysql under Linux, first find the version and environment. After deployment, start Mysql to verify whether the database is running properly.
[@ more@]-- View the LINUX version
[root@sd ~] # cat / etc/issue
Red Hat Enterprise Linux AS release 4 (Nahant)
Kernel r on an m
[root@sd ~] # cat / proc/version
Linux version 2.6.9-5.ELsmp (bhcompile@decompose.build.redhat.com) (gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)) # 1 SMP Wed Jan 5 19:30:39 EST 2005
-- Kernel
[root@sd ~] # uname-r
2.6.9-5.ELsmp
-- View CPU
[root@sd ~] # grep "model name" / proc/cpuinfo
Model name: Intel (R) Xeon (R) CPU 5130 @ 2.00GHz
Model name: Intel (R) Xeon (R) CPU 5130 @ 2.00GHz
Model name: Intel (R) Xeon (R) CPU 5130 @ 2.00GHz
Model name: Intel (R) Xeon (R) CPU 5130 @ 2.00GHz
-- MEM
[root@sd ~] # free
Total used free shared buffers cached
Mem: 4147280 1467312 2679968 0 105028 1141932
-/ + buffers/cache: 220352 3926928
Swap: 4192924 0 4192924
-- Information
[root@sd ~] # cat / proc/cpuinfo
-
-check the linux software management package
[root@sd ~] # rpm-qa system-config-packages
System-config-packages-1.2.23-1
-- displays the mysql installation package
[root@sd] # rpm-Q mysql
Mysql-4.1.7-4.RHEL4.1
[root@sd] # rpm-Q apache
Package apache is not installed
[root@sd] # rpm-Q php
Php-4.3.9-3.1
[root@sd] # rpm-Q perl
Perl-5.8.5-12
-- A detailed list of installation packages
[root@sd ~] # rpm-qa | grep php
Php-gd-4.3.9-3.1
Php-pear-4.3.9-3.1
Php-xmlrpc-4.3.9-3.1
Php-ldap-4.3.9-3.1
Php-pgsql-4.3.9-3.1
Php-devel-4.3.9-3.1
Php-mbstring-4.3.9-3.1
Php-domxml-4.3.9-3.1
Php-ncurses-4.3.9-3.1
Php-odbc-4.3.9-3.1
Php-snmp-4.3.9-3.1
Php-4.3.9-3.1
Php-imap-4.3.9-3.1
[root@sd ~] # rpm-qa | grep mysql
Mysql-devel-4.1.7-4.RHEL4.1
Mysql-4.1.7-4.RHEL4.1
Mysqlclient10-devel-3.23.58-4.RHEL4.1
Mysqlclient10-3.23.58-4.RHEL4.1
Freeradius-mysql-1.0.1-2.RHEL4
Libdbi-dbd-mysql-0.6.5-10.RHEL4.1
[root@sd ~] # rpm-qa | grep apache
[root@sd] # rpm-ql mysql-4.1.7-4.RHEL4.1
/ etc/ld.so.conf.d/mysql-i386.conf
/ etc/init.d/mysqld
/ etc/my.cnf
/ usr/bin/msql2mysql
/ usr/bin/mysql
/ usr/bin/mysql_config
/ usr/bin/mysql_find_rows
/ usr/bin/mysql_tableinfo
/ usr/bin/mysql_waitpid
/ usr/bin/mysqlaccess
/ usr/bin/mysqladmin
/ usr/bin/mysqlbinlog
/ usr/bin/mysqlcheck
/ usr/bin/mysqldump
/ usr/bin/mysqldumpslow
/ usr/bin/mysqlimport
/ usr/bin/mysqlsho
/ usr/share/info/mysql.info.gz
/ usr/share/man/man1/mysql.1.gz
/ usr/share/man/man1/mysqlaccess.1.gz
/ usr/share/man/man1/mysqladmin.1.gz
/ usr/share/man/man1/mysqldump.1.gz
/ usr/share/man/man1/mysqlshow.1.gz
/ usr/share/mysql
-- Starting mysqld daemon with databases from / etc/init.d/mysqld
[root@sd mysql] # / etc/init.d/mysqld
Usage: / etc/init.d/mysqld {start | stop | status | condrestart | restart}
[root@sd mysql] # / etc/init.d/mysqld start
[root@sd mysql] # / etc/init.d/mysqld status
Mysqld (pid 18373) is running...
[root@sd mysql] # 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 22273 0.0.0.015 * LISTEN
Tcp 0 0 0.0.0 0 32770 0.0.0 0 v * LISTEN
Tcp 0 0 0.0.0.0 3306 0.0.0.015 * LISTEN
[root@sd mysql] # mysql-u root-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or g.
Your MySQL connection id is 4 to server version: 4.1.7
Type 'help;' or' h' for help. Type 'c'to clear the buffer.
Mysql >
Check to see if mysql is in the automatic startup list.
/ sbin/chkconfig-- list
[root@sd opt] # mysqladmin-u-p shutdown
Mysqladmin: shutdown failed; error: 'Access denied; you need the SHUTDOWN privilege for this operation'
[root@sd opt] # / etc/init.d/mysqld stop
Stopping MySQL: [OK]
Stopping MySQL: [OK]
[root@sd opt] # ls / var/lib/mysql
Ibdata1 ib_logfile0 ib_logfile1 mysql test
[root@sd opt] # mv / var/lib/mysql / opt/mydata/
[root@sd opt] # ls / var/lib/-alt
[root@sd opt] # ls / opt/mydata/mysql
Ibdata1 ib_logfile0 ib_logfile1 mysql test
[root@sd opt] # cd / opt/mydata/mysql
[root@sd mysql] # ls
Ibdata1 ib_logfile0 ib_logfile1 mysql test
[root@sd mysql] # cd mysql
[root@sd mysql] # / etc/init.d/mysqld start
Timeout error occurred trying to start MySQL Daemon.
Starting MySQL: [FAILED]
[root@sd mysql] # / etc/init.d/mysqld status
Mysqld (pid 18776) is running...
[root@sd mysql] # mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket'/ var/lib/mysql/mysql.sock' (2)
[root@sd mysql] # / etc/init.d/mysqld stop
Stopping MySQL: [OK]
[root@sd mysql] # ps-ef | grep mysql
Root 18845 17994 0 16:27 pts/1 00:00:00 grep mysql
[root@sd mysql] # vi / etc/init.d/mysqld
#! / bin/bash
#
# mysqld This shell script takes care of starting and stopping
# the MySQL subsystem (mysqld).
#
# chkconfig:-64 36
# description: MySQL database server.
# processname: mysqld
# config: / etc/my.cnf
# pidfile: / var/run/mysqld/mysqld.pid
# Source function library.
. / etc/rc.d/init.d/functions
# Source networking configuration.
. / etc/sysconfig/network
Prog= "MySQL"
Datadir= "/ var/lib/mysql"
# datadir= "/ opt/mydata/mysql"
Entering Ex mode. Type "visual" to go to Normal mode.
: wq
"/ etc/rc.d/init.d/mysqld" 111L, 2497C written
[root@sd mysql] # vi / etc/my.cnf
[mysqld]
# datadir=/opt/mydata/mysql
Datadir=/var/lib/mysql
# socket=/opt/mydata/mysql/mysql.sock
Socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
Old_passwords=1
[mysql.server]
User=mysql
Basedir=/var/lib
[mysqld_safe]
Err-log=/var/log/mysqld.log
Pid-file=/var/run/mysqld/mysqld.pid
Entering Ex mode. Type "visual" to go to Normal mode.
: q
[root@sd mysql] # cd / opt/mydata
[root@sd mydata] # ls
Mysql
[root@sd mydata] # mv mysql / var/lib/
[root@sd mydata] # ls / var/lib/mysql
Ibdata1 ib_logfile0 ib_logfile1 mysql test
[root@sd mydata] # / etc/init.d/mysqld status
Mysqld is stopped
[root@sd mydata] # / etc/init.d/mysqld start
Starting MySQL: [OK]
[root@sd mydata] # mysql
Welcome to the MySQL monitor. Commands end with; or g.
Your MySQL connection id is 3 to server version: 4.1.7
Type 'help;' or' h' for help. Type 'c'to clear the buffer.
Mysql > h
For the complete MySQL Manualonline, visit:
Http://www.mysql.com/documentation
For info on technical support from MySQL developers, visit:
Http://www.mysql.com/support
For info on MySQL books, utilities, consultants, etc., visit:
Http://www.mysql.com/portal
List of all MySQL commands:
Note that all text commands must be first on line and end with';'
?) Synonym for `help'.
Clear (c) Clear command.
Connect (r) Reconnect to the server. Optional arguments are db and host.
Delimiter (d) Set query delimiter.
Edit (e) Edit command with $EDITOR.
Ego (G) Send command to mysql server, display result vertically.
Exit (Q) Exit mysql. Same as quit.
Go (g) Send command to mysql server.
Help (h) Display this help.
Nopager (n) Disable pager, print to stdout.
Notee (t) Don't write into outfile.
Pager (P) Set PAGER [to_pager]. Print the query results via PAGER.
Print (p) Print current command.
Prompt (R) Change your mysql prompt.
Quit (Q) Quit mysql.
Rehash (#) Rebuild completion hash.
Source (.) Execute a SQL script file. Takes a file name as an argument.
Status (s) Get status information from the server.
System (!) Execute a system shell command.
Tee (T) Set outfile [to_outfile]. Append everything into given outfile.
Use (u) Use another database. Takes database name as argument.
For server side help, type 'help contents'
Mysql > show databases
+-+
| | Database |
+-+
| | mysql |
| | test |
+-+
2 rows in set (0.00 sec)
Mysql > use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-A
Database changed
Mysql > show tables
+-+
| | Tables_in_mysql |
+-+
| | columns_priv |
| | db |
| | func |
| | help_category |
| | help_keyword |
| | help_relation |
| | help_topic |
| | host |
| | tables_priv |
| | time_zone |
| | time_zone_leap_second |
| | time_zone_name |
| | time_zone_transition |
| | time_zone_transition_type |
| | user |
+-+
15 rows in set (0.00 sec)
Mysql > describe db
+-+ +
| | Field | Type | Null | Key | Default | Extra | |
+-+ +
| | Host | char (60) | | PRI |
| | Db | char (64) | | PRI |
| | User | char (16) | | PRI |
| | Select_priv | enum ('Nickel Magazine Y') | N | |
| | Insert_priv | enum ('Nickel Magazine Y') | N | |
| | Update_priv | enum ('Nickel Magazine Y') | N | |
| | Delete_priv | enum ('Nickel Magazine Y') | N | |
| | Create_priv | enum ('Nickel Magazine Y') | N | |
| | Drop_priv | enum ('Nickel Magazine Y') | N | |
| | Grant_priv | enum ('Nickel Magazine Y') | N | |
| | References_priv | enum ('Nickel Magazine Y') | N | |
| | Index_priv | enum ('Nickel Magazine Y') | N | |
| | Alter_priv | enum ('Nickel Magazine Y') | N | |
| | Create_tmp_table_priv | enum ('Nickel Magazine Y') | N | |
| | Lock_tables_priv | enum ('Nickel Magazine Y') | N | |
+-+ +
15 rows in set (0.00 sec)
Mysql > select * from db
+-+ -+
| | Host | Db | User | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Create_tmp_table_priv | Lock_tables_priv |
+-+ -+
| |% | test | | Y | Y | Y | Y | Y | Y | N | Y | Y | Y | Y | Y | Y |
| |% | test_% | | Y | Y | Y | Y | Y | Y | N | Y | Y | Y | Y | Y | Y |
+-+ -+
2 rows in set (0.00 sec)
Mysql > create database sdtest
Query OK, 1 row affected (0.00 sec)
Mysql > show databases
+-+
| | Database |
+-+
| | mysql |
| | sdtest |
| | test |
+-+
3 rows in set (0.00 sec)
Mysql > show tables
+-+
| | Tables_in_mysql |
+-+
| | columns_priv |
| | db |
| | func |
| | help_category |
| | help_keyword |
| | help_relation |
| | help_topic |
| | host |
| | tables_priv |
| | time_zone |
| | time_zone_leap_second |
| | time_zone_name |
| | time_zone_transition |
| | time_zone_transition_type |
| | user |
+-+
15 rows in set (0.00 sec)
Mysql > use sdtest
Database changed
Mysql > show tables
Empty set (0.00 sec)
Mysql > create table name (id int (3) auto_increment not null primary key,csny date,xm char (9), xy char (9))
Query OK, 0 rows affected (0.00 sec)
Mysql > show tables
+-+
| | Tables_in_sdtest |
+-+
| | name |
+-+
1 row in set (0.00 sec)
Mysql > select * from name
Empty set (0.00 sec)
Mysql > describe name
+-+ +
| | Field | Type | Null | Key | Default | Extra | |
+-+ +
| | id | int (3) | | PRI | NULL | auto_increment | |
| | csny | date | YES | | NULL |
| | xm | char (9) | YES | | NULL |
| | xy | char (9) | YES | | NULL |
+-+ +
4 rows in set (0.00 sec)
Mysql > insert into name values (', '1981-01-10)
Query OK, 1 row affected, 1 warning (0.00 sec)
Mysql > select * from name
+-- +
| | id | csny | xm | xy | |
+-- +
| | 1 | 1981-01-10 | MM | SEXY | |
+-- +
1 row in set (0.00 sec)
[root@sd mydata] # mysql
Welcome to the MySQL monitor. Commands end with; or g.
Your MySQL connection id is 4 to server version: 4.1.7
Type 'help;' or' h' for help. Type 'c'to clear the buffer.
Mysql > use sdtest
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-A
Database changed
Mysql > insert into name values ('', '1981-03-30','GG', 'HANDSOME')
Query OK, 1 row affected, 1 warning (0.00 sec)
Mysql > insert into name values (', '1981-03-30)
Query OK, 1 row affected, 1 warning (0.00 sec)
Mysql > select * from name
+-- +
| | id | csny | xm | xy | |
+-- +
| | 1 | 1981-01-10 | MM | SEXY | |
| | 2 | 1981-03-30 | GG | HANDSOME | |
| | 3 | 1981-03-30 | DY | SMITH | |
+-- +
3 rows in set (0.00 sec)
Mysql > update name set xm='XX' where xm='DY'
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Mysql > select * from name
+-- +
| | id | csny | xm | xy | |
+-- +
| | 1 | 1981-01-10 | MM | SEXY | |
| | 2 | 1981-03-30 | GG | HANDSOME | |
| | 3 | 1981-03-30 | XX | SMITH | |
+-- +
3 rows in set (0.00 sec)
Mysql > grant select, insert,update,delete on *. * to hnzx_hq@ "%" identified by "huangq"
Query OK, 0 rows affected (0.00 sec)
Mysql > grant select, update on sdtest.* to testman@localhost identified by "123"
Query OK, 0 rows affected (0.00 sec)
Mysql > quit
Bye
[root@sd mydata] # mysql-u hnzx_hq-p huangq
Enter password:
ERROR 1045 (28000): Access denied for user 'hnzx_hq'@'localhost' (using password: YES)
[root@sd mydata] # mysql-u hnzx_hq-p
Enter password:
ERROR 1045 (28000): Access denied for user 'hnzx_hq'@'localhost' (using password: YES)
[root@sd mydata] # mysql-u hnzx_hq-p-h
Enter password:
ERROR 1045 (28000): Access denied for user 'hnzx_hq'@'sd.server.gov.com' (using password: YES)
[root@sd mydata] # mysqldump-u root-p-- opt sdtest > back_sdtest
Enter password:
[root@sd mydata] # ls / var/lib/mysql
Ibdata1 ib_logfile0 ib_logfile1 mysql mysql.sock sdtest test
[root@sd mydata] # cd sdtest
-bash: cd: sdtest: No such file or directory
[root@sd mydata] # cd / var/lib/mysql/sdtest
[root@sd sdtest] # ls
Db.opt name.frm name.MYD name.MYI
[root@sd sdtest] # mysqldump-u root-p-- opt sdtest > back_sdtest
Enter password:
[root@sd sdtest] # ls / var/lib/mysql
Ibdata1 ib_logfile0 ib_logfile1 mysql mysql.sock sdtest test
[root@sd sdtest] # cd / var/lib/mysql/sdtest
[root@sd sdtest] # ls
Back_sdtest db.opt name.frm name.MYD name.MYI
[root@sd sdtest] # mysql-u root-p ccc < back_sdtest
Enter password:
ERROR 1049 (42000): Unknown database 'ccc'
[root@sd sdtest] # mysql-u root-p cc < back_sdtest
Enter password:
ERROR 1049 (42000): Unknown database 'cc'
[root@sd sdtest] #
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.