1 / 16

Installation of MySQL

Installation of MySQL. Objectives Install MySQL Contents Getting the enviroment for building MySQL server Rebuilding SRPMS Removing existing Installing new MySQL Verify installation Creating MySQL admin Practical Install MySQL Summary. Developers enviroment needed.

iolana
Télécharger la présentation

Installation of MySQL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Installation of MySQL • Objectives • Install MySQL • Contents • Getting the enviroment for building MySQL server • Rebuilding SRPMS • Removing existing • Installing new MySQL • Verify installation • Creating MySQL admin • Practical • Install MySQL • Summary

  2. Developers enviroment needed • Developers enviroment needed • If you want to install applications from SRPMS or TAR packages • There are many dependencies so for most comfort use: • Get development tools and enviroment is needed: ncurces ncurces-devel binutils gcc glibc-devel gcc-c++ gcc-objc gcc-locale Then click on Update and follow instruction’s # yast

  3. Install original MySQL, Apache & PHP • It is a good idea to have RedHat original servers • You will have all files, and only need to update • There are many dependencies so for most comfort use: • Get the webserver and the nessesary addons: Web Server (add PHP, SQL, PERL) SQL Database (check MySQL) • Then click on Update and follow instruction’s # yast

  4. Rebuild MySQL from SRPMS • Adding user mysqldev • Get MySQL • Since we use SuSE or RedHat which is RPM based we get the SRPMS • Download MySQL SRPM to /usr/local/src • Rebuild Source RPM • This operation needs lot of diskspace > 660 MByte and time • Process take between 1 to 4 hour to complete! # useradd –m –d mysqldev http://dev.mysql.com/downloads/ # cd /usr/local/src # wget http://ftp.sunet.se/pub/unix/databases/relational/mysql/Downloads/MySQL-5.0/MySQL-5.0.18-0.src.rpm # rpmbuild --rebuild MySQL-5.0.18-0.src.rpm

  5. Check rebuilded packages • Rebuilded SRPMS en up in: /usr/src/packages/RPMS/i386 • Check that the rebuild created this files: • SRPMS can also be generated for specific CPU • Then you have to check proper sub-catalogs i486/, i686/. . . # cd /usr/src/packages/RPMS/i586 # ls –1 MySQL-bench-5.0.18-0.i586.rpm MySQL-client-5.0.18-0.i586.rpm MySQL-debuginfo-5.0.18-0.i586.rpm MySQL-devel-5.0.18-0.i586.rpm MySQL-embedded-5.0.18-0.i586.rpm MySQL-Max-5.0.18-0.i586.rpm MySQL-server-5.0.18-0.i586.rpm MySQL-shared-5.0.18-0.i586.rpm

  6. Removing old MySQL and installing new • Removing old MySQL libraries, ignoring dependecies • Installing new MySQL and subcomponents rpm –qa | grep –i mysql . . . mysql-3.23.54a-11 . . . rpm -e --nodeps mysql-3.23.54a-11 cd /usr/src/packages/RPMS/i586 rpm -ivh MySQL-shared-5.0.18-0.i586.rpm rpm -ivh MySQL-server-5.0.18-0.i586.rpm rpm -ivh MySQL-devel-5.0.18-0.i586.rpm rpm -ivh MySQL-client-5.0.18-0.i586.rpm rpm -ivh MySQL-debuginfo-5.0.18-0.i586.rpm

  7. Checking installation • Check that all files are there • The rpm –qa takes some time, have pation • We also installed mysql-admin, as you can see. • The module perl-DBD is needed for API • Use yast to install perl-DBD and mysql-admin rpm -qa | grep -i mysql MySQL-shared-5.0.18-0 MySQL-debuginfo-5.0.18-0 MySQL-server-5.0.18-0 MySQL-client-5.0.18-0 MySQL-devel-5.0.18-0 mysql-administrator-1.0.19-3 perl-DBD-MySQL-2.9004-3

  8. Start service & Create MySQL admin • Starting MySQLd service Before you can do anything with MySQL it must be running and you must have a client installed. Check logfiles tail /var/log/messages to se any startup error • Creating MySQL admin user • Test MySQL # /etc/init.d/mysql start # /usr/bin/mysqladmin -u root password 'qwerty' # /usr/bin/mysqladmin -u root -h server.my-site.com password 'qwerty' # /usr/bin/mysql_fix_privilege_tables # mysql –u root –p Enter password: mysql> create database test; Query OK, 1 row affected (0.00 sec) mysql> show databases; mysql> drop database test; mysql> exit;

  9. Learn SQL basics, create new database • Login as administrator in MySQL • Create a new database • Check that the database exist # mysql -u root -p password:******* mysql>_ mysql> create database gronsaker; Query OK, 1 row affected (0.01 sec) mysql> show databases; +-------------+ | Database | +-------------+ | gronsaker | | mysql | | test | +-------------+ 3 rows in set (0.00 sec)

  10. Learn SQL basics, connect & create • Connect to the database with connect or use • Check if database haves tables for data • Create listuser for anonymous secure read only access • Create the first table vara with product namn and pris - namn and pris is known as columns in table vara • Check that the table vara was created with describe or show mysql> connect gronsaker; Database changed mysql> use gronsaker; Database changed mysql> show tables; mysql> grant select on gronsaker.* to listuser@localhost identified by '123456'; mysql> create table gronsaker.vara(namn char(15), pris float); mysql> describe vara; mysql> show columns from vara;

  11. Learn SQL basics, adding & viewing data • Add a banan worth 5 kr to vara • Add äpplen, tomater, potatis, isbergssallad and jordgubbe • Check that we got our apples etc. Into database mysql> insert into vara (namn,pris) values ('banan','5.0'); mysql> insert into vara (namn,pris) values ('apple','2.0'); mysql> insert into vara (namn,pris) values ('tomat','1.0'); mysql> insert into vara (namn,pris) values ('potatis','1.0'); mysql> insert into vara (namn,pris) values ('isbergssallad','12.0'); mysql> insert into vara (namn,pris) values ('jordgubbe','0.5'); mysql> select * from vara; +---------------+-------+ | namn | pris | +---------------+-------+ | banan | 5 | | apple | 2 | | tomat | 1 | | potatis | 1 | | isbergssallad | 12 | | jordgubbe | 0.5 | +---------------+-------+ 6 rows in set (0.07 sec)

  12. Learn SQL basics, adding new column • Add one column lager to table vara • Check that the new column was created • Set 1000 products in each cathegory mysql> alter table vara add column lager integer; mysql> select lager from vara; +-------+ | lager | +-------+ | | | | | | | | | | | | +-------+ 6 rows in set (0.00 sec) mysql> update vara set lager='1000';

  13. Learn SQL basics, changing data on one post • Check that we now have 1000 products in each cathegory • We have only 500 bananer so update only banan mysql> select * from vara; +-----------------+-----+-------+ | namn | pris| lager | +-----------------+-----+-------+ | banan | 5 | 1000 | | apple | 2 | 1000 | | tomat | 1 | 1000 | | potatis | 1 | 1000 | | isbergssallad | 12 | 1000 | | jordgubbe | 0.5 | 1000 | +-----------------+-----+-------+ 6 rows in set (0.00 sec) mysql> select lager from vara; +-------+ | lager | +-------+ | | | | | | | | | | | | +-------+ 6 rows in set (0.00 sec) mysql> update vara set lager='500' where namn='banan'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0

  14. Learn SQL basics, modifying tables • Add a limited administrator gadmin for database gronsaker • Test the limited administrator • Add 123 gurkor of value 1.1 Kr • We check that we got gurkor mysql> grant delete,insert,select,update on gronsaker.* to gadmin@localhost identified by '123456'; # mysql -u gadmin -p password:****** mysql> use gronsaker mysql> insert into vara (namn,pris,lager) values ('gurka','1.1','123'); Query OK, 1 row affected (0.00 sec); mysql> select * from vara; +-------------+------+-------+ | namn | pris | lager | +-------------+------+-------+ | banan | 5 | 500 | | apple | 2 | 1000 | | tomat | 1 | 1000 | | potatis | 1 | 1000 | | isbergssallad | 12 | 1000 | | jordgubbe | 0.5 | 1000 | | gurka | 1.1 | 123 | +---------------+------+-----+ 7 rows in set (0.00 sec)

  15. Learn SQL basics, working with tables • 5 bananas is sold, update database • Check the new banana status, b% show all that begin with b, like b* • Some more matching expressions mysql> update vara set lager='495' where namn='banan'; mysql> select lager from vara where namn like 'b%'; +-------+ | lager | +-------+ | 495 | +-------+ 1 row in set (0.00 sec) like) % all characters, more than one _ all characters, but only one rlike) regular expressions . All characthers, but only one * all characters, more than one [a-z] any character in the interval

  16. Learn SQL basics, working with tables • Limit your search result to the 3 first found • Which wares costs more than 2 Kr ? • Remove all wares that costs more than 2 Kr • There are offcourse much more to learn about databases. Recomended books: PHP 5 PROGRAMMERING ISBN:9163608006 DEN SNABBA VÄGEN TILL GRUNDERNA I MYSQL ISBN:9163608308 • Next we will setup Apache2 webserver mysql> select * from vara limit 3; mysql> select namn from vara where pris > 2; mysql> delete from vara where pris > 2;

More Related