Raspberry Pi – Software – MySQL
MySQL database
MySQL is een propriëtair opensource-managementsysteem voor relationele databases (RDBMS). SQL is de taal die wordt gebruikt om een database van dit systeem op te bouwen, te bevragen en te onderhouden. MySQL werd allereerst vooral gebruikt voor internettoepassingen zoals fora en gastenboeken, meestal in combinatie met PHP. MySQL vormt de basis van vele internettoepassingen en standalone software.
Installeer MySQL met het volgende commando: sudo apt-get install mysql-server
Als je ook PHP5 hebt geinstalleerd: Installeer MySQL met het volgende commando: sudo apt-get install mysql-server php5-mysql
Tijdens de installatie kan gevraagd worden om het MySQL root wachtwoord in te stellen:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: heirloom-mailx libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient16 libmysqlclient18 libnet-daemon-perl libplrpc-perl mysql-client-5.5 mysql-common mysql-server-5.5 mysql-server-core-5.5 Suggested packages: exim4 mail-transport-agent libipc-sharedcache-perl tinyca Recommended packages: mailx The following NEW packages will be installed: heirloom-mailx libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient16 libmysqlclient18 libnet-daemon-perl libplrpc-perl mysql-client mysql-client-5.5 mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 php5-mysql 0 upgraded, 16 newly installed, 0 to remove and 5 not upgraded. Need to get 10.8 MB of archives. After this operation, 94.9 MB of additional disk space will be used. Do you want to continue [Y/n]? n Abort. root@raspberrypi /etc # sudo apt-get install mysql-server php5-mysql root@raspberrypi /etc # sudo apt-get install mysql-server php5-mysql Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: heirloom-mailx libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient16 libmysqlclient18 libnet-daemon-perl libplrpc-perl mysql-client-5.5 mysql-common mysql-server-5.5 mysql-server-core-5.5 Suggested packages: exim4 mail-transport-agent libipc-sharedcache-perl tinyca Recommended packages: mailx The following NEW packages will be installed: heirloom-mailx libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient16 libmysqlclient18 libnet-daemon-perl libplrpc-perl mysql-client-5.5 mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5 php5-mysql 0 upgraded, 15 newly installed, 0 to remove and 5 not upgraded. Need to get 10.8 MB of archives. After this operation, 94.7 MB of additional disk space will be used. Do you want to continue [Y/n]? y Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libaio1 armhf 0.3.109-3 [8,944 B] Get:2 http://mirrordirector.raspbian.org/raspbian/ wheezy/main mysql-common all 5.5.35+dfsg-0+wheezy1 [84.4 kB] Get:3 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libmysqlclient18 armhf 5.5.35+dfsg-0+wheezy1 [628 kB] Get:4 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libnet-daemon-perl all 0.48-1 [46.2 kB] Get:5 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libplrpc-perl all 0.2020-2 [36.0 kB] Get:6 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libdbi-perl armhf 1.622-1 [895 kB] Get:7 http://mirrordirector.raspbian.org/raspbian/ wheezy/main mysql-client-5.5 armhf 5.5.35+dfsg-0+wheezy1 [1,460 kB] Get:8 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libmysqlclient16 armhf 5.1.62-1 [1,828 kB] Get:9 http://mirrordirector.raspbian.org/raspbian/ wheezy/main mysql-server-core-5.5 armhf 5.5.35+dfsg-0+wheezy1 [3,343 kB] Get:10 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libdbd-mysql-perl armhf 4.021-1 [123 kB] Get:11 http://mirrordirector.raspbian.org/raspbian/ wheezy/main heirloom-mailx armhf 12.5-2 [253 kB] Get:12 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libhtml-template-perl all 2.91-1 [72.0 kB] Get:13 http://mirrordirector.raspbian.org/raspbian/ wheezy/main mysql-server-5.5 armhf 5.5.35+dfsg-0+wheezy1 [1,828 kB] Get:14 http://mirrordirector.raspbian.org/raspbian/ wheezy/main php5-mysql armhf 5.4.4-14+deb7u8 [68.8 kB] Get:15 http://mirrordirector.raspbian.org/raspbian/ wheezy/main mysql-server all 5.5.35+dfsg-0+wheezy1 [82.6 kB] Fetched 10.8 MB in 9s (1,080 kB/s) Preconfiguring packages ... Selecting previously unselected package libaio1:armhf. (Reading database ... 68975 files and directories currently installed.) Unpacking libaio1:armhf (from .../libaio1_0.3.109-3_armhf.deb) ... Selecting previously unselected package mysql-common. Unpacking mysql-common (from .../mysql-common_5.5.35+dfsg-0+wheezy1_all.deb) ... Selecting previously unselected package libmysqlclient18:armhf. Unpacking libmysqlclient18:armhf (from .../libmysqlclient18_5.5.35+dfsg-0+wheezy1_armhf.deb) ... Selecting previously unselected package libnet-daemon-perl. Unpacking libnet-daemon-perl (from .../libnet-daemon-perl_0.48-1_all.deb) ... Selecting previously unselected package libplrpc-perl. Unpacking libplrpc-perl (from .../libplrpc-perl_0.2020-2_all.deb) ... Selecting previously unselected package libdbi-perl. Unpacking libdbi-perl (from .../libdbi-perl_1.622-1_armhf.deb) ... Selecting previously unselected package libmysqlclient16. Unpacking libmysqlclient16 (from .../libmysqlclient16_5.1.62-1_armhf.deb) ... Selecting previously unselected package libdbd-mysql-perl. Unpacking libdbd-mysql-perl (from .../libdbd-mysql-perl_4.021-1_armhf.deb) ... Selecting previously unselected package mysql-client-5.5. Unpacking mysql-client-5.5 (from .../mysql-client-5.5_5.5.35+dfsg-0+wheezy1_armhf.deb) ... Selecting previously unselected package mysql-server-core-5.5. Unpacking mysql-server-core-5.5 (from .../mysql-server-core-5.5_5.5.35+dfsg-0+wheezy1_armhf.deb) ... Processing triggers for man-db ... Setting up mysql-common (5.5.35+dfsg-0+wheezy1) ... Selecting previously unselected package mysql-server-5.5. (Reading database ... 69368 files and directories currently installed.) Unpacking mysql-server-5.5 (from .../mysql-server-5.5_5.5.35+dfsg-0+wheezy1_armhf.deb) ... Selecting previously unselected package php5-mysql. Unpacking php5-mysql (from .../php5-mysql_5.4.4-14+deb7u8_armhf.deb) ... Selecting previously unselected package heirloom-mailx. Unpacking heirloom-mailx (from .../heirloom-mailx_12.5-2_armhf.deb) ... Selecting previously unselected package libhtml-template-perl. Unpacking libhtml-template-perl (from .../libhtml-template-perl_2.91-1_all.deb) ... Selecting previously unselected package mysql-server. Unpacking mysql-server (from .../mysql-server_5.5.35+dfsg-0+wheezy1_all.deb) ... Processing triggers for man-db ... Processing triggers for menu ... Setting up libaio1:armhf (0.3.109-3) ... Setting up libmysqlclient18:armhf (5.5.35+dfsg-0+wheezy1) ... Setting up libnet-daemon-perl (0.48-1) ... Setting up libplrpc-perl (0.2020-2) ... Setting up libdbi-perl (1.622-1) ... Setting up libmysqlclient16 (5.1.62-1) ... Setting up libdbd-mysql-perl (4.021-1) ... Setting up mysql-client-5.5 (5.5.35+dfsg-0+wheezy1) ... Setting up mysql-server-core-5.5 (5.5.35+dfsg-0+wheezy1) ... Setting up mysql-server-5.5 (5.5.35+dfsg-0+wheezy1) ... [ ok ] Stopping MySQL database server: mysqld. 140425 10:00:21 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead. 140425 10:00:21 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead. 140425 10:00:21 [Note] Plugin 'FEDERATED' is disabled. 140425 10:00:21 InnoDB: The InnoDB memory heap is disabled 140425 10:00:21 InnoDB: Mutexes and rw_locks use GCC atomic builtins 140425 10:00:21 InnoDB: Compressed tables use zlib 1.2.7 140425 10:00:21 InnoDB: Using Linux native AIO 140425 10:00:21 InnoDB: Initializing buffer pool, size = 128.0M 140425 10:00:22 InnoDB: Completed initialization of buffer pool 140425 10:00:22 InnoDB: highest supported file format is Barracuda. 140425 10:00:23 InnoDB: Waiting for the background threads to start 140425 10:00:24 InnoDB: 5.5.35 started; log sequence number 1595675 140425 10:00:24 InnoDB: Starting shutdown... 140425 10:00:25 InnoDB: Shutdown completed; log sequence number 1595675 insserv: warning: script 'mathkernel' missing LSB tags and overrides [ ok ] Starting MySQL database server: mysqld . . . .. [info] Checking for tables which need an upgrade, are corrupt or were not closed cleanly.. Setting up php5-mysql (5.4.4-14+deb7u8) ... Creating config file /etc/php5/mods-available/mysql.ini with new version Creating config file /etc/php5/mods-available/mysqli.ini with new version Creating config file /etc/php5/mods-available/pdo_mysql.ini with new version Setting up heirloom-mailx (12.5-2) ... update-alternatives: using /usr/bin/heirloom-mailx to provide /usr/bin/mailx (mailx) in auto mode Setting up libhtml-template-perl (2.91-1) ... Setting up mysql-server (5.5.35+dfsg-0+wheezy1) ... Processing triggers for menu ... |
MySQL instellen
Verbindingen van buitenaf:
Standaard accepteert de MySQL server zoals nu geïnstalleerd op de Raspberry Pi geen connecties van buitenaf (niet van “localhost”), om een MySQL gebruiker in te stellen en te verbinden van buitenaf, volg deze stappen:
1) Bewerk het MySQL configuratiebestand /etc/mysql/my.cnf met het volgende commando: sudo nano /etc/mysql/my.cnf en zoek de regel:
bind-address = 127.0.0.1
Zet hier een hekje voor (comment out), zodat iedereen verbinding kan maken met de MySQL server.
Druk nu op CTRL+O (writeout) en dan op ENTER op het bestand op te slaan, dan vervolgens CTRL+X om nano af te sluiten.
2) Nu moeten we nog toestemming geven voor de desbetreffende gebruiker, je moet hiervoor MySQL via de BASH starten doormiddel van: sudo mysql -uroot -p[wachtwoord]
en voer het volgende commando uit (in MySQL): GRANT ALL ON *.* TO ‘[gebruiker]’@’%.%.%.%’ IDENTIFIED BY ‘[wachtwoord]’;
daarna gevolgd door: Exit
Hierna de MySQL server opnieuw opstarten om wijzigingen van kracht te doen laten komen met het commando: sudo /etc/init.d/mysql restart
Dan de server herstarten om wijzigingen van kracht te doen laten komen met het commando: sudo /etc/init.d/lighttpd force-reload