Download presentation
Presentation is loading. Please wait.
Published byDylan Wade Modified over 9 years ago
1
ITN270.001 Wake Tech1 ITN270 Advanced Internet Databases Lecture 15. General MySQL Administration Topics: –Securing a New MySQL Installation –MySQL Server Startup & Shutdown –Managing User Accounts –Maintaining Log files –Multiple Servers – Updating MySQL
2
ITN270.001 Wake Tech2 Securing a New MySQL Installation After MySQL installation –mysql database user table –include root & anonymous accounts –all the accounts are listed in the user table –test database –No passwords are set up for any user –To Do list: Establish password for root & anonymous accounts Set up accounts for other users
3
ITN270.001 Wake Tech3 Establishing Password for the Initial MySQL Accounts Unix OS: –First Method: run the commands without server started mysqladmin -h localhost -u root password “password” –Second Method: mysql -u root mysql> SET PASSWORD FOR ‘root’@’localhost’ = password(‘password’); – Third Method: mysql -u root mysql>USE mysql; UPDATE user SET Password = PASSWORD(‘password’) WHERE User =‘root’; FLUSH PRIVILEGES;
4
ITN270.001 Wake Tech4 Establishing Password for the Initial MySQL Accounts Delete Anonymous Users Or –REVOKE ALL ON *.* FROM ‘’@’localhost; –REVOKE GRANT OPTION ON *.* FROM ‘’@’localhost’;
5
ITN270.001 Wake Tech5 Setting up Password for a Second Server Two Servers Installed on one Machine –%mysql -u root -p –Enter password just enter here
6
ITN270.001 Wake Tech6 Arranging for MySQL Server Startup & Shutdown UNIX OS: –Server to run as some user other than root –Server to run as the same user all the time –Shutdown mysqladmin -u root -p shutdown –Starup Manually –mysqld_safe –mysql.server Automatically
7
ITN270.001 Wake Tech7 Arranging for MySQL Server Startup & Shutdown Windows OS: –mysqld –mysql --console error message will go to the console window instead of to the error log –Running the Server as a Service mysql-nt --install ~ automatically mysql-nt --install ~ manual –Start or stop the service net start MySql net stop MySql / mysqld-nt --remove
8
ITN270.001 Wake Tech8 Specifying the Startup Options UNIX: File: /etc/my.cnf Windows: my.int or my.cnf
9
ITN270.001 Wake Tech9 Shutting Down the Server /etc/rc.d/init.d/mysql stop mysqladmin -p -u root shutdown net stop MySql kill -TERM PID kill -9 PID (last choice)
10
ITN270.001 Wake Tech10 Managing MySQL User Accounts To specify – which user can connect to the server – where they can connect from – what they can do while connected GRANT –creates accounts & specifies privileges REVOKE –remove privileges from existing accounts
11
ITN270.001 Wake Tech11 Creating New Users & Granting Privileges Syntax grant privileges (columns) on what to account IDENTIFIED BY ‘password’ REQUIRE encription requirements WITH grant or resource management options
12
ITN270.001 Wake Tech12 Creating New Users & Granting Privileges Who can connect & from where –example: GRANT ALL ON alwoodsampdb.* TO ‘alwood’@’localhost’ IDENTIFIED BY ‘password’ or GRANT ALL ON alwoodsampdb.* TO ‘alwood’@’et219-3’ IDENTIFIED BY ‘password’ or GRANT ALL ON alwoodsampdb.* TO ‘alwood’@’%’ IDENTIFIED BY ‘password’
13
ITN270.001 Wake Tech13 Creating New Users & Granting Privileges Privileges –Administrative: Privilege SpecifierOperation Allowed by Privilege CREATE TEMPORARY TABLES Create temporary tables EXECUTEExecute stored procedures (reserved for future use) FILERead and write files on the server host GRANT OPTIONGrant the account’s privileges to other accounts LOCK TABLESExplicitly lock tables with LOCK TABLES statements PROCESSView information about the threads executing within the server RELOADReload the grant tables or flush the logs or caches REPLICATION CLIENTAsk about master and slave server locations REPLICATION SLAVE Act as a replication slave server SHOW DATABASESIssue SHOW DATABASES statements SHUTDOWN Shut down the server SUPER Kill threads and perform other supervisory operations
14
ITN270.001 Wake Tech14 Creating New Users & Granting Privileges Privileges Privilege SpecifierOperation Allowed by Privilege ALTER Alter tables and indexes CREATE Create databases and tables DELETE Delete existing rows from tables DROPDrop (remove) databases and tables INDEX Create or drop indexes INSERT Insert new rows into tables REFERENCESUnused (reserved for future use) SELECT Retrieve existing rows from tables UPDATE Modify existing table rows
15
ITN270.001 Wake Tech15 Creating New Users & Granting Privileges Secure connection: – GRANT ALL ON alwoodsampdb.* TO ‘alwood’@’localhost’ IDENTIFIED BY ‘password’ REQUIRE SSL –SSL - SQCURE SOCKETS LAYER Administrative privilege –GRANT ALL ON alwoodsampdb.* to ‘alwood’@’localhost’ IDENTIFIED BY ‘password’ WITH GRANT OPTION –or –GRANT GRANT OPTION ON alwoodsampdb.* to ‘alwood’@’localhost’ IDENTIFIED BY ‘password’
16
ITN270.001 Wake Tech16 Creating New Users & Granting Privileges Limit user’s resource GRANT ALL ON alwoodsampdb.* to to ‘alwood’@’localhost’ IDENTIFIED BY ‘password’ WITH MAX_CONNECTION_PER_HOUR 10 MAX_QUERIES_PER_HOUR 200 MAX_UPDATE_PER_HOUR 50
17
ITN270.001 Wake Tech17 Revoking Privileges and Removing Users Syntax: –REVOKE privileges (columns) ON what FROM account; –Example: REVOKE DELETE, UPDATE ON sampdb.* FROM ‘userid’@’localhost’; –REMOVE USER: %mysql -u root mysql>USE mysql; mysql>DELETE FROM user WHERE User = ‘userid’ and Host = ‘%’; mysql>FLUSH PRIVILEGES;
18
ITN270.001 Wake Tech18 Changing Passwords or Resetting Lost Password 1: mysql>UPDATE user SET Password=PASSWORD(‘password’) -> WHERE User=‘userid’ and Host = ‘localhost’; mysql> FLUSH PRIVILEGES; 2: mysql> SET PASSWORD FOR ‘userid’@’localhost’ = PASSWORD(‘password’); 3: mysql> GRANT USAGE ON *.* TO ‘userid’ IDENTIFY BY ‘password’;
19
ITN270.001 Wake Tech19 Maintaining Log Files The general query log The slow-query log The update log The binary update log & the binary log index file Error log
20
ITN270.001 Wake Tech20 Maintaining Log Files To enable logging, use the options –please refer to MySQL Manual for more information
21
ITN270.001 Wake Tech21 Running Multiple Servers Configuring & Compiling Different Servers: –Different locations Startup Options –using mysqld_multi –Check /etc/my.cnf file –Commands: mysqld_multi --nolog start 32351 mysqld_multi --nolog --user=root --password=‘password’ stop 32351
22
ITN270.001 Wake Tech22 Updating MySQL
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.