If you remember all the way back to how the coding lessons in C started, they started by looking at different datatypes, like ints long int etc, each requiring different memory spaces or being able to store different sized numbers.
The same thing is true in MySQL.
MySQL is a database server, often whenever you're making a website you have a few diffeerent things to think about.
Lets imagine you;re making an on line magazine, or a piece of forum software, you;re going to have authors, (that's a relatively short bit of text, -who's name is over 20 letters?)
but then you also have article text, or posts etc that's going to be a fairly hefty chunk of text.
So lets look at the kind of thing you'll use to have article titles, or by lines, that's likely to be a varchar type.
Varchar is like a string, you specify how much text you want to be able to store in the field. so for a name you may decide that 20 characters is enough, and you;d specify varchar(20).
for storing text there are a few different types of data field.
Notably these don't hold a number of characters, they actually hold an amount of data which is measured in bytes.
(this is important as you might be using a double byte character set -then you can only store half as much text by character count.
So, the data types are
Tinytext which can store 256 bytes,
Text which can store 65,535 bytes (64Kb)
Mediumtext -which can store 16,777,215 bytes (16MB)
Longtext 4,294,967,295 bytes that's a huge 4GB!!!
so how does this work? a 4GB chunk of text is huge to just be a row on a table.
well, the MyISAM tables actually have a maximum size of 65,535 bytes (that means a row can only be that size.) -but surely if a text field can be that by itself.
What happens is that a pointer is stored with the row data that points to the large text chunk, that file pointer is anywhere between 1 - 4 bytes. That way large data is store outside of the normal row.
Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts
Monday, June 24, 2013
Monday, June 03, 2013
LAM(Pi)
So over the weekend I decided to use my Raspberry pi to do a little bit of website development.
This is an interesting task. I've been actually developing the site on a windows box, but as I plan to host on inux evenutally I thought that I should test on linux, usually this would mean spinning up a VM, but I thought since I have the Raspberry Pi, (and I want to think of a web enabled hardware project also, now would be a good time to get to installing some standard LAMP type tools
first install apache
apt-get apache2
then php
apt-get php5
then mysql
apt-get mysql-server
then the PHP and my sql tools
apt-get php5-mysql
then I want to have a live AND a test site, to you need to configure apache.
I'm putting my test site on an alternate port (I suppose I could use named hosts)
do as well as making a new site in site-available and linking it to sites enabled you have to edit ports.conf too
now, a load of people suggest installing phpmyadmin.
This is a pretty cool tool, I've used it plenty of times before when developing siets. but, I don't reall want that on this box, the reason is, that when I used it before there were pretty much no graphical tools for mysql administration, it was CLI or developing some kind of app.
since Oracle bought MySQL the've written some pretty nice GUI connect and administer tools. (which is weird because the oracle ones are pretty bloated and shite)
then I want to use the GUI tools on my windows machine to admin the mysel server
So I keep getting a connecttion failed error
can't connect to server 10060
Turn out that this means taht the server isn't listening,
but it should be, I am actually running code on it, my site is working perfect databases are being accessed.
Oh wait, turns out that the default config is to listen for connecttions to local host only.
So edit /etc/mysql/my.cnf and change the bind address from bind 127.0.0.1 to bind (your ip address) (make sure you set a static address, you don;t want this changing!!)
But wait, now the tools are saying they can see the server, but throw up the message
Host 192.168.1.11 (my computer) is not allowed to connect to this MySQL server.
You have to grant the user access from specific IP locations. (a pretty neat sucurity feature I guess)
To do this you'll need to log on to your MySQL installation as root.
(so from the command line (Via SSH if you like))
mysql -u root -p
Then you'll want to use the MySQL equivalent of the system databases,
use mysql
And finally, grant access to the machine to be able to connect to the server:
grant all on *.* to root@'[clinet IP]' identified by 'password'
(or grant select insert delete on *.* to web_site_user@'web_site_server_IP' identified by 'web_site_user password')
This is an interesting task. I've been actually developing the site on a windows box, but as I plan to host on inux evenutally I thought that I should test on linux, usually this would mean spinning up a VM, but I thought since I have the Raspberry Pi, (and I want to think of a web enabled hardware project also, now would be a good time to get to installing some standard LAMP type tools
first install apache
apt-get apache2
then php
apt-get php5
then mysql
apt-get mysql-server
then the PHP and my sql tools
apt-get php5-mysql
then I want to have a live AND a test site, to you need to configure apache.
I'm putting my test site on an alternate port (I suppose I could use named hosts)
do as well as making a new site in site-available and linking it to sites enabled you have to edit ports.conf too
now, a load of people suggest installing phpmyadmin.
This is a pretty cool tool, I've used it plenty of times before when developing siets. but, I don't reall want that on this box, the reason is, that when I used it before there were pretty much no graphical tools for mysql administration, it was CLI or developing some kind of app.
since Oracle bought MySQL the've written some pretty nice GUI connect and administer tools. (which is weird because the oracle ones are pretty bloated and shite)
then I want to use the GUI tools on my windows machine to admin the mysel server
So I keep getting a connecttion failed error
can't connect to server 10060
Turn out that this means taht the server isn't listening,
but it should be, I am actually running code on it, my site is working perfect databases are being accessed.
Oh wait, turns out that the default config is to listen for connecttions to local host only.
So edit /etc/mysql/my.cnf and change the bind address from bind 127.0.0.1 to bind (your ip address) (make sure you set a static address, you don;t want this changing!!)
But wait, now the tools are saying they can see the server, but throw up the message
Host 192.168.1.11 (my computer) is not allowed to connect to this MySQL server.
You have to grant the user access from specific IP locations. (a pretty neat sucurity feature I guess)
To do this you'll need to log on to your MySQL installation as root.
(so from the command line (Via SSH if you like))
mysql -u root -p
Then you'll want to use the MySQL equivalent of the system databases,
use mysql
And finally, grant access to the machine to be able to connect to the server:
grant all on *.* to root@'[clinet IP]' identified by 'password'
(or grant select insert delete on *.* to web_site_user@'web_site_server_IP' identified by 'web_site_user password')
Subscribe to:
Posts (Atom)